Imports System.Diagnostics
Imports Welcome
Imports System.Runtime.Serialization.Formatters.Binary

Partial Class SimulationPage
    Inherits System.Web.UI.Page

    Private userID As String = "userID"
    Private currentSimulationID As String = "currentSimulationID"
    Private currentTrainingID As String = "currentTrainingID"
    Private currentInjuryID As String = "currentInjuryID"
    Private currentPlayerID As String = "currentPlayerID"
    Private copyPlayerID As String = "copyPlayerID"

    Private simulationsIDCol As Collection
    Private trainingsIDCol As Collection
    Private injuriesIDCol As Collection
    Private playersIDCol As Collection
    Private errorsIDCol As Collection
    Private reportsIDCol As Collection

    Private simulationsIDColKey As String = "simulationsIDColKey"
    Private trainingsIDColKey As String = "trainingsIDColKey"
    Private injuriesIDColKey As String = "injuriesIDColKey"
    Private playersIDColKey As String = "playersIDColKey"
    Private errorsIDColKey As String = "errorsIDColKey"
    Private reportsIDColKey As String = "reportsIDColKey"


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load


        If (Not IsPostBack) Then

            Dim id As String = (Request.Params("id"))

            If (Session.Item(id) = CInt(id)) Then
                ViewState.Add(userID, DBConnection.FET_USER_BY_ID(id))

                welcomeLabel.Text = "Welcome " & CType(ViewState.Item(userID), User).UserName

                LoadSimulationsForUser()
                LoadTrainingsForUser()
                LoadInjuriesForUser()
                LoadPlayersForUser()

            Else
                'came in from another page..did not log in
                Response.Redirect("Welcome.aspx")
            End If
           
        End If






    End Sub


    Public Function DotColorings() As String
        Return " ToolTip=""tooltip"" "
    End Function

#Region "LOADing"

    Protected Sub LoadSimulationsForUser()

        'clear the buttons and hide
        For t As Integer = 0 To UpdatePanel1Tbl.Rows.Count - 1
            Dim tr As TableRow = UpdatePanel1Tbl.Rows(t)
            Dim cell As TableCell = tr.Cells(0)
            Dim btn As Button = cell.Controls(0)
            btn.Text = ""

            btn.Visible = False
        Next

        simulationsIDCol = DBConnection.FET_SIMULATIONS(CType(ViewState.Item(userID), User).ID)

        ViewState.Add(simulationsIDColKey, simulationsIDCol)
        'max of 3

        For s As Integer = 1 To simulationsIDCol.Count

            Dim tr As TableRow = UpdatePanel1Tbl.Rows(s - 1)
            'tr.Visible = True
            Dim cell As TableCell = tr.Cells(0)
            Dim btn As Button = cell.Controls(0)
            btn.Text = CType(simulationsIDCol.Item(s), Base).Name

            btn.Visible = True

        Next

        Me.SimulationListDiv.Visible = True
    End Sub

    Protected Sub LoadTrainingsForUser()
        '
        'clear the buttons and hide
        For t As Integer = 0 To UpdatePanel2Tbl.Rows.Count - 1
            Dim tr As TableRow = UpdatePanel2Tbl.Rows(t)
            Dim cell As TableCell = tr.Cells(0)
            Dim btn As Button = cell.Controls(0)
            btn.Text = ""

            btn.Visible = False
        Next

        trainingsIDCol = DBConnection.FET_TRAININGS(CType(ViewState.Item(userID), User).ID)
        ViewState.Add(trainingsIDColKey, trainingsIDCol)

        For s As Integer = 1 To trainingsIDCol.Count

            Dim tr As TableRow = UpdatePanel2Tbl.Rows(s - 1)
            'tr.Visible = True
            Dim cell As TableCell = tr.Cells(0)
            Dim btn As Button = cell.Controls(0)
            btn.Text = CType(trainingsIDCol.Item(s), Base).Name

            btn.Visible = True

        Next

        Me.TrainingListDiv.Visible = True


    End Sub

    Protected Sub LoadInjuriesForUser()
        '
        'clear the buttons and hide
        For t As Integer = 0 To UpdatePanel3Tbl.Rows.Count - 1
            Dim tr As TableRow = UpdatePanel3Tbl.Rows(t)
            Dim cell As TableCell = tr.Cells(0)
            Dim btn As Button = cell.Controls(0)
            btn.Text = ""

            btn.Visible = False
        Next

        injuriesIDCol = DBConnection.FET_INJURIES(CType(ViewState.Item(userID), User).ID)
        ViewState.Add(injuriesIDColKey, injuriesIDCol)


        For s As Integer = 1 To injuriesIDCol.Count

            Dim tr As TableRow = UpdatePanel3Tbl.Rows(s - 1)
            'tr.Visible = True
            Dim cell As TableCell = tr.Cells(0)
            Dim btn As Button = cell.Controls(0)
            btn.Text = CType(injuriesIDCol.Item(s), Base).Name

            btn.Visible = True

        Next

        Me.InjuryListDiv.Visible = True

    End Sub

    Protected Sub LoadPlayersForUser()
        '
        'clear the buttons and hide
        For t As Integer = 0 To UpdatePanel4Tbl.Rows.Count - 1
            Dim tr As TableRow = UpdatePanel4Tbl.Rows(t)
            Dim cell As TableCell = tr.Cells(0)
            Dim btn As Button = cell.Controls(0)
            btn.Text = ""

            btn.Visible = False
        Next

        playersIDCol = DBConnection.FET_PLAYERS(CType(ViewState.Item(userID), User).ID)
        ViewState.Add(playersIDColKey, playersIDCol)

        For s As Integer = 1 To playersIDCol.Count

            Dim tr As TableRow = UpdatePanel4Tbl.Rows(s - 1)
            'tr.Visible = True
            Dim cell As TableCell = tr.Cells(0)
            Dim btn As Button = cell.Controls(0)
            btn.Text = CType(playersIDCol.Item(s), Base).Name

            btn.Visible = True

        Next

        Me.PlayerListDiv.Visible = True
    End Sub

#End Region

#Region "ADDing"

    Protected Sub SimulationAddBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SimulationAddBtn.Click
        ShowAddSimulationScreen()
    End Sub

    Private Sub ShowAddSimulationScreen()
        Me.addsimulationcontentdiv.Visible = True
        Me.editdeletesimulationcontentdiv.Visible = False
        Me.addtrainingcontentdiv.Visible = False
        Me.editdeletetrainingcontentdiv.Visible = False
        Me.addinjurycontentdiv.Visible = False
        Me.editdeleteinjurycontentdiv.Visible = False
        Me.addplayercontentdiv.Visible = False
        Me.editdeleteplayercontentdiv.Visible = False
    End Sub

    Protected Sub TrainingAddBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TrainingAddBtn.Click
        ShowAddTrainingScreen()

    End Sub

    Private Sub ShowAddTrainingScreen()
        Me.addsimulationcontentdiv.Visible = False
        Me.editdeletesimulationcontentdiv.Visible = False
        Me.addtrainingcontentdiv.Visible = True
        Me.editdeletetrainingcontentdiv.Visible = False
        Me.addinjurycontentdiv.Visible = False
        Me.editdeleteinjurycontentdiv.Visible = False
        Me.addplayercontentdiv.Visible = False
        Me.editdeleteplayercontentdiv.Visible = False
    End Sub

    Protected Sub InjuryAddBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles InjuryAddBtn.Click

        ShowAddInjuriesScreen()

    End Sub

    Private Sub ShowAddInjuriesScreen()
        Me.addsimulationcontentdiv.Visible = False
        Me.editdeletesimulationcontentdiv.Visible = False
        Me.addtrainingcontentdiv.Visible = False
        Me.editdeletetrainingcontentdiv.Visible = False
        Me.addinjurycontentdiv.Visible = True
        Me.editdeleteinjurycontentdiv.Visible = False
        Me.addplayercontentdiv.Visible = False
        Me.editdeleteplayercontentdiv.Visible = False
    End Sub

    Protected Sub PlayerAddBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PlayerAddBtn.Click

        ShowAddPlayersScreen()

    End Sub

    Private Sub ShowAddPlayersScreen()
        Me.addsimulationcontentdiv.Visible = False
        Me.editdeletesimulationcontentdiv.Visible = False
        Me.addtrainingcontentdiv.Visible = False
        Me.editdeletetrainingcontentdiv.Visible = False
        Me.addinjurycontentdiv.Visible = False
        Me.editdeleteinjurycontentdiv.Visible = False
        Me.addplayercontentdiv.Visible = True
        Me.editdeleteplayercontentdiv.Visible = False

        fill()
    End Sub

#End Region

#Region "EDITing"


    Protected Function SimulReportBtnClick(ByVal simIndx As Integer) As String
        Dim simId As Integer = CType(simulationsIDCol.Item(simIndx), Base).ID

        Return "Report.aspx?sid=" & simId & "&uid=" & CType(ViewState.Item(userID), User).ID
    End Function


    Protected Sub Simul1Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Simul1Btn.Click
        SimulBtnClick(1)
    End Sub

    Protected Sub Simul2Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Simul2Btn.Click
        SimulBtnClick(2)
    End Sub

    Protected Sub Simul3Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Simul3Btn.Click
        SimulBtnClick(3)
    End Sub

    Protected Sub Simul4Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Simul4Btn.Click
        SimulBtnClick(4)
    End Sub

    Protected Sub Simul5Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Simul5Btn.Click
        SimulBtnClick(5)
    End Sub

    Private Sub SimulBtnClick(ByVal indx As Integer)
        simulationsIDCol = ViewState.Item(simulationsIDColKey)

        Dim simulation As Base = simulationsIDCol.Item(indx)

        ViewState.Add(currentSimulationID, simulation.ID)

        EditSimulationNameTxtB.Text = CType(simulationsIDCol.Item(indx), Base).Name
        EditSimulationDescTxtB.Text = CType(simulationsIDCol.Item(indx), Base).Desc

        RebuildEditSimulationScreen(Nothing)

        RebuildEditSimulationScreen(simulation)

        

        ShowEditSimulationScreen()

    End Sub

    Private Sub RebuildEditSimulationScreen(ByVal simulation As Base)
        Dim headerBackColor As Drawing.Color = Drawing.Color.Cyan
        Dim dataBackColor As Drawing.Color = Drawing.Color.Khaki
        Dim rowHeight As Integer = 25


        If simulation Is Nothing Then
            'blank out everything

            'hide the training seasons
            For tr As Integer = 1 To Cons.MAX_TRAININGS
                CType(TrainingSeasonsTable.Rows(tr).Cells(0).Controls(0), Label).Text = "Training" & tr & "Lbl"

                For s As Integer = 1 To Cons.MAX_SEASONS
                    CType(TrainingSeasonsTable.Rows(tr).Cells(s).Controls(0), RadioButton).Checked = False

                Next
                TrainingSeasonsTable.Rows(tr).Visible = False
            Next

            'hide the injury label age ranges
            For tr As Integer = 1 To Cons.MAX_INJURIES

                CType(InjuryAgeRangesTable.Rows(tr).Cells(0).Controls(0), Label).Text = "Injury" & tr & "Lbl"
                CType(InjuryAgeRangesTable.Rows(tr).Cells(1).Controls(0), TextBox).Text = "0"
                CType(InjuryAgeRangesTable.Rows(tr).Cells(2).Controls(0), TextBox).Text = "0"
                CType(InjuryAgeRangesTable.Rows(tr).Cells(3).Controls(0), TextBox).Text = "0"
                CType(InjuryAgeRangesTable.Rows(tr).Cells(4).Controls(0), TextBox).Text = "0"
                CType(InjuryAgeRangesTable.Rows(tr).Cells(5).Controls(0), TextBox).Text = "0"
                CType(InjuryAgeRangesTable.Rows(tr).Cells(6).Controls(0), TextBox).Text = "0"
                CType(InjuryAgeRangesTable.Rows(tr).Cells(7).Controls(0), TextBox).Text = "0"

                InjuryAgeRangesTable.Rows(tr).Visible = False
            Next


            'hide the players selection
            For tr As Integer = 1 To Cons.MAX_PLAYERS
                'CType(PlayerSelectionsTable.Rows(tr).Cells(0).Controls(0), Label).Text = ""

                CType(PlayerSelectionsTable.Rows(tr).Cells(0).Controls(0), CheckBox).Checked = False
                CType(PlayerSelectionsTable.Rows(tr).Cells(0).Controls(0), CheckBox).Text = ""
                PlayerSelectionsTable.Rows(tr).Visible = False
            Next

        Else
            'populate with simulation

            'populate the training labels
            trainingsIDCol = ViewState.Item(trainingsIDColKey)
            Dim numOfTrainings As Integer = trainingsIDCol.Count

            'populate the training seasons

            TrainingSeasonsTable.Rows(0).Height = rowHeight
            TrainingSeasonsTable.Rows(0).Font.Bold = True
            TrainingSeasonsTable.Rows(0).Font.Size = FontSize.Large
            TrainingSeasonsTable.Rows(0).BackColor = headerBackColor
            For tr As Integer = 1 To numOfTrainings
                CType(TrainingSeasonsTable.Rows(tr).Cells(0).Controls(0), Label).Text = CType(trainingsIDCol.Item(tr), Base).Name

                Dim t As Integer = CType(trainingsIDCol.Item(tr), Base).ID

                TrainingSeasonsTable.Rows(tr).Height = rowHeight
                TrainingSeasonsTable.Rows(tr).BackColor = dataBackColor

                Dim isTrue As Boolean
                Dim s As Integer = 1
                For Each season As String In Cons.GET_SEASONS
                    Dim tm As Integer = CType(simulation.Setup, SimulationSetup).TrainingMap.Item(season)
                    If (tm = t) Then
                        isTrue = True
                    Else
                        isTrue = False
                    End If

                    CType(TrainingSeasonsTable.Rows(tr).Cells(s).Controls(0), RadioButton).Checked = isTrue
                    s += 1
                Next

                TrainingSeasonsTable.Rows(tr).Visible = True
            Next



            'populate the injury labels
            injuriesIDCol = ViewState.Item(injuriesIDColKey)
            Dim numOfInjuries As Integer = injuriesIDCol.Count

            InjuryAgeRangesTable.Rows(0).Height = rowHeight
            InjuryAgeRangesTable.Rows(0).Font.Bold = True
            InjuryAgeRangesTable.Rows(0).Font.Size = FontSize.Large
            InjuryAgeRangesTable.Rows(0).BackColor = headerBackColor
            InjuryAgeRangesTable.Rows(0).CssClass = "AgeRangeLbl"
            For tr As Integer = 1 To numOfInjuries
                Dim injuryID As Integer = CType(injuriesIDCol.Item(tr), Base).ID
                Dim injuryName As String = CType(injuriesIDCol.Item(tr), Base).Name
                Dim ageRangeMap As Hashtable = CType(simulation.Setup, SimulationSetup).InjuriesMap.Item(injuryID)

                If ageRangeMap Is Nothing Then
                    ageRangeMap = New Hashtable
                    ageRangeMap.Add(Cons.AGERANGE1, 0)
                    ageRangeMap.Add(Cons.AGERANGE2, 0)
                    ageRangeMap.Add(Cons.AGERANGE3, 0)
                    ageRangeMap.Add(Cons.AGERANGE4, 0)
                    ageRangeMap.Add(Cons.AGERANGE5, 0)
                    ageRangeMap.Add(Cons.AGERANGE6, 0)
                    ageRangeMap.Add(Cons.AGERANGE7, 0)

                End If
                CType(InjuryAgeRangesTable.Rows(tr).Cells(0).Controls(0), Label).Text = injuryName

                CType(InjuryAgeRangesTable.Rows(tr).Cells(1).Controls(0), TextBox).Text = ageRangeMap.Item(Cons.AGERANGE1)
                CType(InjuryAgeRangesTable.Rows(tr).Cells(2).Controls(0), TextBox).Text = ageRangeMap.Item(Cons.AGERANGE2)
                CType(InjuryAgeRangesTable.Rows(tr).Cells(3).Controls(0), TextBox).Text = ageRangeMap.Item(Cons.AGERANGE3)
                CType(InjuryAgeRangesTable.Rows(tr).Cells(4).Controls(0), TextBox).Text = ageRangeMap.Item(Cons.AGERANGE4)
                CType(InjuryAgeRangesTable.Rows(tr).Cells(5).Controls(0), TextBox).Text = ageRangeMap.Item(Cons.AGERANGE5)
                CType(InjuryAgeRangesTable.Rows(tr).Cells(6).Controls(0), TextBox).Text = ageRangeMap.Item(Cons.AGERANGE6)
                CType(InjuryAgeRangesTable.Rows(tr).Cells(7).Controls(0), TextBox).Text = ageRangeMap.Item(Cons.AGERANGE7)

                InjuryAgeRangesTable.Rows(tr).Visible = True

            Next

            'populate the injury age ranges
           



            playersIDCol = ViewState.Item(playersIDColKey)
            Dim numOfPlayers As Integer = playersIDCol.Count


            'populate the player selections
            PlayerSelectionsTable.Rows(0).Height = rowHeight
            PlayerSelectionsTable.Rows(0).Font.Bold = True
            PlayerSelectionsTable.Rows(0).Font.Size = FontSize.Large
            PlayerSelectionsTable.Rows(0).BackColor = headerBackColor

            For tr As Integer = 1 To numOfPlayers
                Dim isChecked As Boolean
                Dim pm As Integer = CType(simulation.Setup, SimulationSetup).PlayerMap.Item("Player" & tr)
                Dim pi As Integer = CType(playersIDCol.Item(tr), Base).ID
                Dim pn As String = CType(playersIDCol.Item(tr), Base).Name

                If (pm = pi) Then
                    isChecked = True
                Else
                    isChecked = False
                End If

                PlayerSelectionsTable.Rows(tr).Height = rowHeight
                PlayerSelectionsTable.Rows(tr).BackColor = dataBackColor
                PlayerSelectionsTable.Rows(tr).Visible = True

                'CType(PlayerSelectionsTable.Rows(tr).Cells(0).Controls(0), Label).Text = pn

                CType(PlayerSelectionsTable.Rows(tr).Cells(0).Controls(0), CheckBox).Checked = isChecked
                CType(PlayerSelectionsTable.Rows(tr).Cells(0).Controls(0), CheckBox).Text = pn

            Next

        End If

    End Sub

    Private Sub ShowEditSimulationScreen()
        Me.addsimulationcontentdiv.Visible = False
        Me.editdeletesimulationcontentdiv.Visible = True
        Me.addtrainingcontentdiv.Visible = False
        Me.editdeletetrainingcontentdiv.Visible = False
        Me.addinjurycontentdiv.Visible = False
        Me.editdeleteinjurycontentdiv.Visible = False
        Me.addplayercontentdiv.Visible = False
        Me.editdeleteplayercontentdiv.Visible = False
    End Sub



    Protected Sub Training1Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training1Btn.Click
        TrainingBtnClick(1)
    End Sub

    Protected Sub Training2Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training2Btn.Click
        TrainingBtnClick(2)
    End Sub

    Protected Sub Training3Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training3Btn.Click
        TrainingBtnClick(3)

    End Sub

    Protected Sub Training4Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training4Btn.Click

        TrainingBtnClick(4)

    End Sub

    Protected Sub Training5Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training5Btn.Click
        TrainingBtnClick(5)

    End Sub

    Protected Sub Training6Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training6Btn.Click
        TrainingBtnClick(6)

    End Sub

    Protected Sub Training7Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training7Btn.Click
        TrainingBtnClick(7)

    End Sub

    Protected Sub Training8Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training8Btn.Click
        TrainingBtnClick(8)

    End Sub

    Protected Sub Training9Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training9Btn.Click
        TrainingBtnClick(9)

    End Sub

    Protected Sub Training10Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training10Btn.Click
        TrainingBtnClick(10)

    End Sub

    Protected Sub Training11Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training11Btn.Click
        TrainingBtnClick(11)

    End Sub

    Protected Sub Training12Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training12Btn.Click
        TrainingBtnClick(12)

    End Sub

    Protected Sub Training13Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training13Btn.Click
        TrainingBtnClick(13)

    End Sub

    Protected Sub Training14Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training14Btn.Click
        TrainingBtnClick(14)

    End Sub

    Protected Sub Training15Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training15Btn.Click
        TrainingBtnClick(15)

    End Sub

    Protected Sub Training16Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training16Btn.Click
        TrainingBtnClick(16)

    End Sub

    Protected Sub Training17Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training17Btn.Click
        TrainingBtnClick(17)

    End Sub

    Protected Sub Training18Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training18Btn.Click
        TrainingBtnClick(18)

    End Sub

    Protected Sub Training19Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training19Btn.Click
        TrainingBtnClick(19)

    End Sub

    Protected Sub Training20Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training20Btn.Click
        TrainingBtnClick(20)

    End Sub

    Private Sub TrainingBtnClick(ByVal indx As Integer)
        trainingsIDCol = ViewState.Item(trainingsIDColKey)


        Dim training As Base = trainingsIDCol.Item(indx)

        ViewState.Add(currentTrainingID, training.ID)

        EditTrainingNameTxtB.Text = training.Name
        EditTrainingDescTxtB.Text = training.Desc


        'empty out the current selections
        RebuildEditTrainingScreen(Nothing)
        'populate the selections
        'RebuildEditTrainingScreen(training)
        RebuildEditTrainingScreen(training)

        ShowEditTrainingScreen()


    End Sub

    Private Sub RebuildEditTrainingScreen(ByVal training As Base)

        Dim headerBackColor As Drawing.Color = Drawing.Color.Cyan
        Dim dataBackColor As Drawing.Color = Drawing.Color.Khaki
        Dim rowHeight As Integer = 25

        TrainingAgeTable.Rows(0).Height = rowHeight
        TrainingAgeTable.Rows(0).Font.Bold = True
        TrainingAgeTable.Rows(0).BackColor = headerBackColor
        TrainingAgeTable.Rows(0).Cells(0).CssClass = "AgeRangeLbl"
        TrainingAgeTable.Rows(0).Cells(0).Font.Size = FontSize.Large
        TrainingAgeTable.Rows(0).Cells(1).CssClass = "AgeRangeLbl"
        TrainingAgeTable.Rows(0).Cells(1).Font.Size = FontSize.Large
        TrainingAgeTable.Rows(0).Cells(2).CssClass = "AgeRangeLbl"
        TrainingAgeTable.Rows(0).Cells(2).Font.Size = FontSize.Large
        TrainingAgeTable.Rows(0).Cells(3).CssClass = "AgeRangeLbl"
        TrainingAgeTable.Rows(0).Cells(3).Font.Size = FontSize.Large
        TrainingAgeTable.Rows(0).Cells(4).CssClass = "AgeRangeLbl"
        TrainingAgeTable.Rows(0).Cells(4).Font.Size = FontSize.Large
        TrainingAgeTable.Rows(0).Cells(5).CssClass = "AgeRangeLbl"
        TrainingAgeTable.Rows(0).Cells(5).Font.Size = FontSize.Large
        TrainingAgeTable.Rows(0).Cells(6).CssClass = "AgeRangeLbl"
        TrainingAgeTable.Rows(0).Cells(6).Font.Size = FontSize.Large


        'build drop downs
        AttributesList.Items.Clear()
        For Each attribute As String In Cons.GET_ATTRIBUTES
            AttributesList.Items.Add(attribute)
        Next
        'AttributesList.SelectedIndex = 0

        CategoriesList.Items.Clear()
        For Each category As String In Cons.GET_CATEGORIES
            CategoriesList.Items.Add(category)
        Next
        'CategoriesList.SelectedIndex = 0

        'make selections
        If (training Is Nothing) Then
            'defaults
            IdealGrowthTxtB.Text = ""
            TrainingAttribute.Checked = True

            TrainingPositions.Checked = True


            For Each tr As TableRow In TrainingPositionsAllocationTable.Rows
                CType(tr.Cells(1).Controls(0), TextBox).Text = "0"
            Next
            For Each tr As TableRow In TrainingZonesAllocationTable.Rows
                CType(tr.Cells(1).Controls(0), TextBox).Text = "0"
            Next
        Else
            'selected

            Dim setup As TrainingSetup = training.Setup


            IdealGrowthTxtB.Text = setup.PointsForFUllTraining

            TrainingAgeRange1TxtB.Text = setup.TrainingAgeMap.Item(Cons.AGERANGE1)
            TrainingAgeRange2TxtB.Text = setup.TrainingAgeMap.Item(Cons.AGERANGE2)
            TrainingAgeRange3TxtB.Text = setup.TrainingAgeMap.Item(Cons.AGERANGE3)
            TrainingAgeRange4TxtB.Text = setup.TrainingAgeMap.Item(Cons.AGERANGE4)
            TrainingAgeRange5TxtB.Text = setup.TrainingAgeMap.Item(Cons.AGERANGE5)
            TrainingAgeRange6TxtB.Text = setup.TrainingAgeMap.Item(Cons.AGERANGE6)
            TrainingAgeRange7TxtB.Text = setup.TrainingAgeMap.Item(Cons.AGERANGE7)



            If setup.TrainingType = Cons.TRAINING_TYPE_Category Then
                TrainingAttribute.Checked = False
                TrainingCategory.Checked = True
                CategoriesList.SelectedValue = setup.TrainingTypeSelected
                'setup.TrainingType = Cons.TRAINING_TYPE_Category
            Else
                TrainingAttribute.Checked = True
                TrainingCategory.Checked = False
                AttributesList.SelectedValue = Cons.ATTRIBUTE_Crossing
                setup.TrainingType = Cons.TRAINING_TYPE_Attribute
            End If




            If (setup.TrainingAffecting = Cons.TRAINING_AFFECTING_Zones) Then
                TrainingPositions.Checked = False
                TrainingZones.Checked = True

                KeeperTxtB.Text = setup.Keeper
                DefenseTxtB.Text = setup.Defense
                MidfieldTxtB.Text = setup.Midfield
                ForwardTxtB.Text = setup.Forward

                GKTxtB.Text = "0"

                SWTxtB.Text = "0"
                RBTxtB.Text = "0"
                RWBTxtB.Text = "0"
                RCBTxtB.Text = "0"
                CBTxtB.Text = "0"
                LCBTxtB.Text = "0"
                LWBTxtB.Text = "0"
                LBTxtB.Text = "0"

                RMTxtB.Text = "0"
                RAMTxtB.Text = "0"
                RCMTxtB.Text = "0"
                RDMTxtB.Text = "0"
                CMTxtB.Text = "0"
                CAMTxtB.Text = "0"
                CDMTxtB.Text = "0"
                LDMTxtB.Text = "0"
                LCMTxtB.Text = "0"
                LAMTxtB.Text = "0"
                LMTxtB.Text = "0"

                RWTxtB.Text = "0"
                RFTxtB.Text = "0"
                RSTxtB.Text = "0"
                CFTxtB.Text = "0"
                STTxtB.Text = "0"
                LSTxtB.Text = "0"
                LFTxtB.Text = "0"
                LWTxtB.Text = "0"

            Else
                TrainingPositions.Checked = True
                TrainingZones.Checked = False
                setup.TrainingAffecting = Cons.TRAINING_AFFECTING_Positions

                GKTxtB.Text = setup.GK

                SWTxtB.Text = setup.SW
                RBTxtB.Text = setup.RB
                RWBTxtB.Text = setup.RWB
                RCBTxtB.Text = setup.RCB
                CBTxtB.Text = setup.CB
                LCBTxtB.Text = setup.LCB
                LWBTxtB.Text = setup.LWB
                LBTxtB.Text = setup.LB

                RMTxtB.Text = setup.RM
                RAMTxtB.Text = setup.RAM
                RCMTxtB.Text = setup.RCM
                RDMTxtB.Text = setup.RDM
                CMTxtB.Text = setup.CM
                CAMTxtB.Text = setup.CAM
                CDMTxtB.Text = setup.CDM
                LDMTxtB.Text = setup.LDM
                LCMTxtB.Text = setup.LCM
                LAMTxtB.Text = setup.LAM
                LMTxtB.Text = setup.LM

                RWTxtB.Text = setup.RW
                RFTxtB.Text = setup.RF
                RSTxtB.Text = setup.RS
                CFTxtB.Text = setup.CF
                STTxtB.Text = setup.ST
                LSTxtB.Text = setup.LS
                LFTxtB.Text = setup.LF
                LWTxtB.Text = setup.LW


                KeeperTxtB.Text = "0"
                DefenseTxtB.Text = "0"
                MidfieldTxtB.Text = "0"
                ForwardTxtB.Text = "0"
            End If


        End If
    End Sub

    Private Sub ShowEditTrainingScreen()
        Me.addsimulationcontentdiv.Visible = False
        Me.editdeletesimulationcontentdiv.Visible = False
        Me.addtrainingcontentdiv.Visible = False
        Me.editdeletetrainingcontentdiv.Visible = True
        Me.addinjurycontentdiv.Visible = False
        Me.editdeleteinjurycontentdiv.Visible = False
        Me.addplayercontentdiv.Visible = False
        Me.editdeleteplayercontentdiv.Visible = False
    End Sub




    Protected Sub Injury1Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury1Btn.Click
        InjuryBtnClick(1)
    End Sub

    Protected Sub Injury2Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury2Btn.Click
        InjuryBtnClick(2)
    End Sub

    Protected Sub Injury3Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury3Btn.Click
        InjuryBtnClick(3)
    End Sub

    Protected Sub Injury4Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury4Btn.Click
        InjuryBtnClick(4)
    End Sub

    Protected Sub Injury5Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury5Btn.Click
        InjuryBtnClick(5)
    End Sub

    Protected Sub Injury6Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury6Btn.Click
        InjuryBtnClick(6)
    End Sub

    Protected Sub Injury7Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury7Btn.Click
        InjuryBtnClick(7)
    End Sub

    Protected Sub Injury8Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury8Btn.Click
        InjuryBtnClick(8)
    End Sub

    Protected Sub Injury9Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury9Btn.Click
        InjuryBtnClick(9)
    End Sub

    Protected Sub Injury10Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury10Btn.Click
        InjuryBtnClick(10)
    End Sub

    Protected Sub Injury11Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury11Btn.Click
        InjuryBtnClick(11)

    End Sub

    Protected Sub Injury12Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury12Btn.Click
        InjuryBtnClick(12)

    End Sub

    Protected Sub Injury13Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury13Btn.Click
        InjuryBtnClick(13)

    End Sub

    Protected Sub Injury14Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury14Btn.Click
        InjuryBtnClick(14)

    End Sub

    Protected Sub Injury15Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury15Btn.Click
        InjuryBtnClick(15)

    End Sub

    Protected Sub Injury16Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury16Btn.Click
        InjuryBtnClick(16)

    End Sub

    Protected Sub Injury17Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury17Btn.Click
        InjuryBtnClick(17)

    End Sub

    Protected Sub Injury18Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury18Btn.Click
        InjuryBtnClick(18)

    End Sub

    Protected Sub Injury19Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury19Btn.Click
        InjuryBtnClick(19)

    End Sub

    Protected Sub Injury20Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury20Btn.Click
        InjuryBtnClick(20)

    End Sub

    Private Sub InjuryBtnClick(ByVal indx As Integer)

        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        ViewState.Add(currentInjuryID, CType(injuriesIDCol.Item(indx), Base).ID)

        EditInjuryNameTxtB.Text = CType(injuriesIDCol.Item(indx), Base).Name
        EditInjuryDescTxtB.Text = CType(injuriesIDCol.Item(indx), Base).Desc

        Dim headerBackColor As Drawing.Color = Drawing.Color.Cyan
        Dim dataBackColor As Drawing.Color = Drawing.Color.Khaki
        Dim rowHeight As Integer = 25

        RecoveryAgeTable.Rows(0).Height = rowHeight
        RecoveryAgeTable.Rows(0).Font.Bold = True
        RecoveryAgeTable.Rows(0).Font.Size = FontSize.Large
        RecoveryAgeTable.Rows(0).BackColor = headerBackColor


        'clear the fields
        RecoveryWeeksTxtB.Text = ""

        'clear the table
        For tr As Integer = 1 To Me.RecoveryAgeTable.Rows.Count - 1
            CType(Me.RecoveryAgeTable.Rows.Item(tr).Cells.Item(1).Controls(0), TextBox).Text = "0"

        Next

        'build the table
        RecoveryWeeksTxtB.Text = CType(CType(injuriesIDCol.Item(indx), Base).Setup, InjurySetup).RecoveryWeeks

        Dim r As Integer = 0
        For Each key As String In Cons.GET_AGERANGES

            CType(Me.RecoveryAgeTable.Rows.Item(1).Cells.Item(r).Controls(0), TextBox).Text = CType(CType(injuriesIDCol.Item(indx), Base).Setup, InjurySetup).RecoveryAgeMap.Item(key)
            r += 1
        Next


        ShowEditInjuryScreen()

    End Sub

    Private Sub ShowEditInjuryScreen()
        Me.addsimulationcontentdiv.Visible = False
        Me.editdeletesimulationcontentdiv.Visible = False
        Me.addtrainingcontentdiv.Visible = False
        Me.editdeletetrainingcontentdiv.Visible = False
        Me.addinjurycontentdiv.Visible = False
        Me.editdeleteinjurycontentdiv.Visible = True
        Me.addplayercontentdiv.Visible = False
        Me.editdeleteplayercontentdiv.Visible = False
    End Sub




    Protected Sub Player1Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player1Btn.Click
        PlayerBtnClick(1)
    End Sub

    Protected Sub Player2Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player2Btn.Click
        PlayerBtnClick(2)
    End Sub

    Protected Sub Player3Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player3Btn.Click
        PlayerBtnClick(3)
    End Sub

    Protected Sub Player4Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player4Btn.Click
        PlayerBtnClick(4)
    End Sub

    Protected Sub Player5Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player5Btn.Click
        PlayerBtnClick(5)
    End Sub

    Protected Sub Player6Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player6Btn.Click
        PlayerBtnClick(6)
    End Sub

    Protected Sub Player7Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player7Btn.Click
        PlayerBtnClick(7)
    End Sub

    Protected Sub Player8Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player8Btn.Click
        PlayerBtnClick(8)
    End Sub

    Protected Sub Player9Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player9Btn.Click
        PlayerBtnClick(9)
    End Sub

    Protected Sub Player10Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player10Btn.Click
        PlayerBtnClick(10)
    End Sub

    Protected Sub Player11Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player11Btn.Click
        PlayerBtnClick(11)

    End Sub

    Protected Sub Player12Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player12Btn.Click
        PlayerBtnClick(12)

    End Sub

    Protected Sub Player13Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player13Btn.Click
        PlayerBtnClick(13)

    End Sub

    Protected Sub Player14Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player14Btn.Click
        PlayerBtnClick(14)

    End Sub

    Protected Sub Player15Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player15Btn.Click
        PlayerBtnClick(15)

    End Sub

    Protected Sub Player16Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player16Btn.Click
        PlayerBtnClick(16)

    End Sub

    Protected Sub Player17Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player17Btn.Click
        PlayerBtnClick(17)

    End Sub

    Protected Sub Player18Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player18Btn.Click
        PlayerBtnClick(18)

    End Sub

    Protected Sub Player19Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player19Btn.Click
        PlayerBtnClick(19)

    End Sub

    Protected Sub Player20Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player20Btn.Click
        PlayerBtnClick(20)

    End Sub

    Protected Sub Player21Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player21Btn.Click
        PlayerBtnClick(21)

    End Sub

    Protected Sub Player22Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player22Btn.Click
        PlayerBtnClick(22)

    End Sub

    Protected Sub Player23Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player23Btn.Click
        PlayerBtnClick(23)

    End Sub

    Protected Sub Player24Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player24Btn.Click
        PlayerBtnClick(24)

    End Sub

    Protected Sub Player25Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player25Btn.Click
        PlayerBtnClick(25)

    End Sub

    Protected Sub Player26Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player26Btn.Click
        PlayerBtnClick(26)

    End Sub

    Protected Sub Player27Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player27Btn.Click
        PlayerBtnClick(27)

    End Sub

    Protected Sub Player28Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player28Btn.Click
        PlayerBtnClick(28)

    End Sub

    Protected Sub Player29Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player29Btn.Click
        PlayerBtnClick(29)

    End Sub

    Protected Sub Player30Btn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player30Btn.Click
        PlayerBtnClick(30)

    End Sub


    Private Sub PlayerBtnClick(ByVal indx As Integer)

        playersIDCol = ViewState.Item(playersIDColKey)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)

        PositionCombox.Items.Clear()
        For Each position As String In Cons.GET_POSITIONS
            PositionCombox.Items.Add(position)
        Next

        InjuryTypeCombox.Items.Clear()
        InjuryTypeCombox.Items.Add(Cons.NONE)
        For Each injury As Base In injuriesIDCol
            InjuryTypeCombox.Items.Add(injury.Name)
        Next

        RetireRangeCombox.Items.Clear()
        For Each ageRange As String In Cons.GET_AGERANGEVALUES
            RetireRangeCombox.Items.Add(ageRange)
        Next

        Dim colWidth As Integer = 125
        ViewState.Add(currentPlayerID, CType(playersIDCol.Item(indx), Base).ID)

        EditPlayerNameTxtB.Text = CType(playersIDCol.Item(indx), Base).Name
        EditPlayerDescTxtB.Text = CType(playersIDCol.Item(indx), Base).Desc

        Dim setup As PlayerSetup = CType(CType(playersIDCol.Item(indx), Base).Setup, PlayerSetup)

        GeneralCategoryTable.Rows(0).Cells(0).Width = colWidth
        CType(GeneralCategoryTable.Rows(1).Cells(1).Controls(0), TextBox).Text = setup.Age
        CType(GeneralCategoryTable.Rows(2).Cells(1).Controls(0), TextBox).Text = setup.Number
        CType(GeneralCategoryTable.Rows(3).Cells(1).Controls(0), DropDownList).SelectedValue = setup.Position
        CType(GeneralCategoryTable.Rows(4).Cells(1).Controls(0), TextBox).Text = Math.Round(setup.ProbabiltyOfInjury * 100)
        CType(GeneralCategoryTable.Rows(5).Cells(1).Controls(0), DropDownList).SelectedValue = setup.RetireRange

        InjuryCategoryTable.Rows(0).Cells(0).Width = colWidth

        CType(InjuryCategoryTable.Rows(1).Cells(1).Controls(0), DropDownList).SelectedValue = setup.InjuryType
        CType(InjuryCategoryTable.Rows(2).Cells(1).Controls(0), TextBox).Text = setup.RecoveryLeft

        AttackingCategoryTable.Rows(0).Cells(0).Width = colWidth
        CType(AttackingCategoryTable.Rows(1).Cells(1).Controls(0), TextBox).Text = setup.Crossing
        CType(AttackingCategoryTable.Rows(2).Cells(1).Controls(0), TextBox).Text = setup.Finishing
        CType(AttackingCategoryTable.Rows(3).Cells(1).Controls(0), TextBox).Text = setup.Heading
        CType(AttackingCategoryTable.Rows(4).Cells(1).Controls(0), TextBox).Text = setup.Short_pass
        CType(AttackingCategoryTable.Rows(5).Cells(1).Controls(0), TextBox).Text = setup.Volleys


        PowerCategoryTable.Rows(0).Cells(0).Width = colWidth
        CType(PowerCategoryTable.Rows(1).Cells(1).Controls(0), TextBox).Text = setup.Shot_power
        CType(PowerCategoryTable.Rows(2).Cells(1).Controls(0), TextBox).Text = setup.Jumping
        CType(PowerCategoryTable.Rows(3).Cells(1).Controls(0), TextBox).Text = setup.Stamina
        CType(PowerCategoryTable.Rows(4).Cells(1).Controls(0), TextBox).Text = setup.Strength
        CType(PowerCategoryTable.Rows(5).Cells(1).Controls(0), TextBox).Text = setup.Long_shot


        MentalityCategoryTable.Rows(0).Cells(0).Width = colWidth
        CType(MentalityCategoryTable.Rows(1).Cells(1).Controls(0), TextBox).Text = setup.Aggression
        CType(MentalityCategoryTable.Rows(2).Cells(1).Controls(0), TextBox).Text = setup.Tactical_awareness
        CType(MentalityCategoryTable.Rows(3).Cells(1).Controls(0), TextBox).Text = setup.Positioning
        CType(MentalityCategoryTable.Rows(4).Cells(1).Controls(0), TextBox).Text = setup.Penalties
        CType(MentalityCategoryTable.Rows(5).Cells(1).Controls(0), TextBox).Text = setup.Vision



        SkillCategoryTable.Rows(0).Cells(0).Width = colWidth
        CType(SkillCategoryTable.Rows(1).Cells(1).Controls(0), TextBox).Text = setup.BallControl
        CType(SkillCategoryTable.Rows(2).Cells(1).Controls(0), TextBox).Text = setup.Curve
        CType(SkillCategoryTable.Rows(3).Cells(1).Controls(0), TextBox).Text = setup.Dribbling
        CType(SkillCategoryTable.Rows(4).Cells(1).Controls(0), TextBox).Text = setup.Freekick
        CType(SkillCategoryTable.Rows(5).Cells(1).Controls(0), TextBox).Text = setup.Long_pass


        MovementCategoryTable.Rows(0).Cells(0).Width = colWidth
        CType(MovementCategoryTable.Rows(1).Cells(1).Controls(0), TextBox).Text = setup.Acceleration
        CType(MovementCategoryTable.Rows(2).Cells(1).Controls(0), TextBox).Text = setup.Agility
        CType(MovementCategoryTable.Rows(3).Cells(1).Controls(0), TextBox).Text = setup.Balance
        CType(MovementCategoryTable.Rows(4).Cells(1).Controls(0), TextBox).Text = setup.Reactions
        CType(MovementCategoryTable.Rows(5).Cells(1).Controls(0), TextBox).Text = setup.Sprint


        DefendingCategoryTable.Rows(0).Cells(0).Width = colWidth
        CType(DefendingCategoryTable.Rows(1).Cells(1).Controls(0), TextBox).Text = setup.Marking
        CType(DefendingCategoryTable.Rows(2).Cells(1).Controls(0), TextBox).Text = setup.Slide_tackle
        CType(DefendingCategoryTable.Rows(3).Cells(1).Controls(0), TextBox).Text = setup.Standing_tackle


        GoalkeeperCategoryTable.Rows(0).Cells(0).Width = colWidth
        CType(GoalkeeperCategoryTable.Rows(1).Cells(1).Controls(0), TextBox).Text = setup.Diving
        CType(GoalkeeperCategoryTable.Rows(2).Cells(1).Controls(0), TextBox).Text = setup.Handling
        CType(GoalkeeperCategoryTable.Rows(3).Cells(1).Controls(0), TextBox).Text = setup.Kicking
        CType(GoalkeeperCategoryTable.Rows(4).Cells(1).Controls(0), TextBox).Text = setup.One_on_one
        CType(GoalkeeperCategoryTable.Rows(5).Cells(1).Controls(0), TextBox).Text = setup.Reflexes

        ShowEditPlayerScreen()
    End Sub

    Private Sub ShowEditPlayerScreen()
        Me.addsimulationcontentdiv.Visible = False
        Me.editdeletesimulationcontentdiv.Visible = False
        Me.addtrainingcontentdiv.Visible = False
        Me.editdeletetrainingcontentdiv.Visible = False
        Me.addinjurycontentdiv.Visible = False
        Me.editdeleteinjurycontentdiv.Visible = False
        Me.addplayercontentdiv.Visible = False
        Me.editdeleteplayercontentdiv.Visible = True
    End Sub

#End Region

#Region "New SAVing"

    Protected Sub NewSimulationSaveBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles NewSimulationSaveBtn.Click

        simulationsIDCol = ViewState.Item(simulationsIDColKey)

        If (simulationsIDCol.Count = Cons.MAX_SIMULATIONS) Then

            MsgBox("Already maxed " & Environment.NewLine & "out", MsgBoxStyle.OkOnly, "Limit Reached")

            NewSimulationNameTxtB.Text = ""
            NewSimulationDescTxtB.Text = ""

            Return
        End If




        If (NewSimulationNameTxtB.Text.Length = 0) Then
            MsgBox("Please enter a valid 'Name'.", MsgBoxStyle.OkOnly, "Error")
            Return
        ElseIf (NewSimulationDescTxtB.Text.Length = 0) Then
            MsgBox("Please enter a valid 'Description'.", MsgBoxStyle.OkOnly, "Error")
            Return
        End If

        Dim simulName As String = NewSimulationNameTxtB.Text
        Dim simulDesc As String = NewSimulationDescTxtB.Text
        Dim status As Integer = 0 '
        Dim setup As String = New SimulationSetup().DefaultXML
        Dim uId As Integer = CType(ViewState.Item(userID), User).ID


        DBConnection.INS_NEW_DEFAULT_SIMULATION(simulName, simulDesc, status, setup, uId)

        LoadSimulationsForUser()

        NewSimulationNameTxtB.Text = ""
        NewSimulationDescTxtB.Text = ""
    End Sub





    Protected Sub NewTrainingSaveBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles NewTrainingSaveBtn.Click

        trainingsIDCol = ViewState.Item(trainingsIDColKey)

        If (trainingsIDCol.Count = Cons.MAX_TRAININGS) Then

            MsgBox("Already maxed out", MsgBoxStyle.OkOnly, "Limit Reached")

            NewTrainingNameTxtB.Text = ""
            NewTrainingDescTxtB.Text = ""

            Return
        End If

        If (NewTrainingNameTxtB.Text.Length = 0) Then
            MsgBox("Please enter a valid 'Name'.", MsgBoxStyle.OkOnly, "Error")
            Return
        ElseIf (NewTrainingDescTxtB.Text.Length = 0) Then
            MsgBox("Please enter a valid 'Description'.", MsgBoxStyle.OkOnly, "Error")
            Return
        End If

        Dim trainingName As String = NewTrainingNameTxtB.Text
        Dim trainingDesc As String = NewTrainingDescTxtB.Text
        Dim setup As String = New TrainingSetup().DefaultXML
        Dim uId As Integer = CType(ViewState.Item(userID), User).ID


        DBConnection.INS_NEW_DEFAULT_TRAINING(trainingName, trainingDesc, setup, uId)

        LoadTrainingsForUser()

        NewTrainingNameTxtB.Text = ""
        NewTrainingDescTxtB.Text = ""

    End Sub

    Protected Sub NewInjurySaveBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles NewInjurySaveBtn.Click

        injuriesIDCol = ViewState.Item(injuriesIDColKey)

        If (injuriesIDCol.Count = Cons.MAX_INJURIES) Then

            MsgBox("Already maxed out", MsgBoxStyle.OkOnly, "Limit Reached")

            NewInjuryNameTxtB.Text = ""
            NewInjuryDescTxtB.Text = ""

            Return
        End If

        If (NewInjuryNameTxtB.Text.Length = 0) Then
            MsgBox("Please enter a valid 'Name'.", MsgBoxStyle.OkOnly, "Error")
            Return
        ElseIf (NewInjuryDescTxtB.Text.Length = 0) Then
            MsgBox("Please enter a valid 'Description'.", MsgBoxStyle.OkOnly, "Error")
            Return
        End If

        Dim name As String = NewInjuryNameTxtB.Text
        Dim desc As String = NewInjuryDescTxtB.Text
        Dim setup As String = New InjurySetup().DefaultXML() '"<Setup />"
        Dim uId As Integer = CType(ViewState.Item(userID), User).ID


        DBConnection.INS_NEW_DEFAULT_INJURY(name, desc, setup, uId)

        LoadInjuriesForUser()

        NewInjuryNameTxtB.Text = ""
        NewInjuryDescTxtB.Text = ""

    End Sub

    Protected Sub NewPlayerSaveBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles NewPlayerSaveBtn.Click

        playersIDCol = ViewState.Item(playersIDColKey)

        If (playersIDCol.Count = Cons.MAX_PLAYERS) Then

            MsgBox("Already maxed out", MsgBoxStyle.OkOnly, "Limit Reached")

            NewPlayerNameTxtB.Text = ""
            NewPlayerDescTxtB.Text = ""

            Return
        End If

        If (NewPlayerNameTxtB.Text.Length = 0) Then
            MsgBox("Please enter a valid 'Name'.", MsgBoxStyle.OkOnly, "Error")
            Return
        ElseIf (NewPlayerDescTxtB.Text.Length = 0) Then
            MsgBox("Please enter a valid 'Description'.", MsgBoxStyle.OkOnly, "Error")
            Return
        End If

        Dim name As String = NewPlayerNameTxtB.Text
        Dim desc As String = NewPlayerDescTxtB.Text
        Dim setup As String = New PlayerSetup().DefaultXML() '"<Setup />"
        Dim uId As Integer = CType(ViewState.Item(userID), User).ID

        DBConnection.INS_NEW_DEFAULT_PLAYER(name, desc, setup, uId)

        LoadPlayersForUser()

        NewPlayerNameTxtB.Text = ""
        NewPlayerDescTxtB.Text = ""

    End Sub

    Protected Sub CopyPlayerSaveBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles CopyPlayerSaveBtn.Click
        playersIDCol = ViewState.Item(playersIDColKey)

        If (playersIDCol.Count = Cons.MAX_PLAYERS) Then

            MsgBox("Already maxed out", MsgBoxStyle.OkOnly, "Limit Reached")

            NewPlayerNameTxtB.Text = ""
            NewPlayerDescTxtB.Text = ""

            Return
        End If

        If (NewPlayerNameTxtB.Text.Length = 0) Then
            MsgBox("Please enter a valid 'Name'.", MsgBoxStyle.OkOnly, "Error")
            Return
        ElseIf (NewPlayerDescTxtB.Text.Length = 0) Then
            MsgBox("Please enter a valid 'Description'.", MsgBoxStyle.OkOnly, "Error")
            Return
        End If

        Dim name As String = NewPlayerNameTxtB.Text
        Dim desc As String = NewPlayerDescTxtB.Text
        Dim setup As String = CType(ViewState.Item(copyPlayerID), Base).SetupToXML
        Dim uId As Integer = CType(ViewState.Item(userID), User).ID


        DBConnection.INS_NEW_DEFAULT_PLAYER(name, desc, setup, uId)

        LoadPlayersForUser()

        NewPlayerNameTxtB.Text = ""
        NewPlayerDescTxtB.Text = ""

    End Sub

#End Region

#Region "Existing SAVing"



    Protected Sub SimulationReportBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SimulationReportBtn.Click
        Dim simId As Integer = ViewState.Item(currentSimulationID)


        ' Response.Redirect("ReportPage.aspx?sid=" & simId & "&uid=" & CType(ViewState.Item(userID), User).ID)
        Response.Redirect("Report.aspx?sId=" & simId & "&uId=" & CType(ViewState.Item(userID), User).ID)


        'look up all the reports sorted by timestamp for sId = simId
    End Sub


    Private Function PopulateErrorTable(ByVal errors As Collection) As Boolean


        errorsTable.Rows().Clear()
        errorsTable.Visible = False

        For Each row As ErrorRow In errors
            Dim field As New Label
            Dim value As New Label
            Dim message As New Label

            Dim cell1 As New TableCell
            Dim cell2 As New TableCell
            Dim cell3 As New TableCell

            field.Text = row.Field
            value.Text = row.Value
            message.Text = row.Message

            cell1.Controls.Add(field)
            cell2.Controls.Add(value)
            cell3.Controls.Add(message)

            Dim tblRow As New TableRow
            tblRow.Cells.Add(cell1)
            tblRow.Cells.Add(cell2)
            tblRow.Cells.Add(cell3)


            errorsTable.Rows.Add(tblRow)

        Next

        If errors.Count > 0 Then
            errorsTable.Visible = True
            Return True
        Else
            Return False
        End If

    End Function
    Protected Sub EditSimulationSaveBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles EditSimulationSaveBtn.Click

        Dim name As String = EditSimulationNameTxtB.Text
        Dim desc As String = EditSimulationDescTxtB.Text
        Dim setup As String = GetSimulationByID(ViewState.Item(currentSimulationID)).SetupToXML()

        Dim errors As Collection = GetSimulationByID(ViewState.Item(currentSimulationID)).ValidateBase

        If errors.Count = 0 Then
            'if valid, then save
            DBConnection.UPD_SIMULATION(name, desc, setup, ViewState.Item(currentSimulationID))

            LoadSimulationsForUser()
        Else
            Dim hasErrors As Boolean = PopulateErrorTable(errors)
        End If

    End Sub

    Protected Sub EditTrainingSaveBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles EditTrainingSaveBtn.Click
        Dim name As String = EditTrainingNameTxtB.Text
        Dim desc As String = EditTrainingDescTxtB.Text
        Dim setup As String = GetTrainingByID(ViewState.Item(currentTrainingID)).SetupToXML()

        Dim errors As Collection = GetTrainingByID(ViewState.Item(currentTrainingID)).ValidateBase

        If errors.Count = 0 Then
            'if valid, then save
            DBConnection.UPD_TRAINING(name, desc, setup, ViewState.Item(currentTrainingID))

            LoadTrainingsForUser()
        Else
            Dim hasErrors As Boolean = PopulateErrorTable(errors)
        End If





    End Sub



    Protected Sub EditInjuryNameTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles EditInjuryNameTxtB.TextChanged
        GetInjuryByID(ViewState.Item(currentInjuryID)).Name = EditInjuryNameTxtB.Text.Trim
    End Sub
    Protected Sub EditInjuryDescTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles EditInjuryDescTxtB.TextChanged
        GetInjuryByID(ViewState.Item(currentInjuryID)).Desc = EditInjuryDescTxtB.Text.Trim
    End Sub
    Protected Sub EditInjurySaveBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles EditInjurySaveBtn.Click
        Dim name As String = GetInjuryByID(ViewState.Item(currentInjuryID)).Name
        Dim desc As String = GetInjuryByID(ViewState.Item(currentInjuryID)).Desc
        Dim setup As String = GetInjuryByID(ViewState.Item(currentInjuryID)).SetupToXML()

        Dim errors As Collection = GetInjuryByID(ViewState.Item(currentInjuryID)).ValidateBase

        If (errors Is Nothing) Then
            DBConnection.UPD_INJURY(name, desc, setup, ViewState.Item(currentInjuryID))

            LoadInjuriesForUser()

        Else

            ErrorList.Rows.Clear()

            For Each row As ErrorRow In errors
                Dim field As New Label
                Dim value As New Label
                Dim message As New Label


                field.Text = row.Field
                value.Text = row.Value
                message.Text = row.Message

                Dim cell1 As New TableCell
                Dim cell2 As New TableCell
                Dim cell3 As New TableCell

                cell1.Controls.Add(field)
                cell2.Controls.Add(value)
                cell3.Controls.Add(message)

                Dim tblRow As New TableRow
                tblRow.Cells.Add(cell1)
                tblRow.Cells.Add(cell2)
                tblRow.Cells.Add(cell3)


                ErrorList.Rows.Add(tblRow)

            Next
            ErrorList.Visible = True

            'Dim strScript As String = "<script language=javascript>window.open('Validator.aspx')</script>"
            'ClientScript.RegisterClientScriptBlock(Me.GetType(), "strScript", strScript)
            'Session("field1") = "value1"



        End If



    End Sub

    Protected Sub EditPlayerSaveBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles EditPlayerSaveBtn.Click

        Dim name As String = EditPlayerNameTxtB.Text
        Dim desc As String = EditPlayerDescTxtB.Text
        Dim setup As String = GetPlayerByID(ViewState.Item(currentPlayerID)).SetupToXML()

        DBConnection.UPD_PLAYER(name, desc, setup, ViewState.Item(currentPlayerID))

        LoadPlayersForUser()

    End Sub

#End Region

#Region "DELETing"

    Protected Sub DeleteSimulationBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DeleteSimulationBtn.Click

        DBConnection.DELETE_SIMULATION(ViewState.Item(currentSimulationID))

        LoadSimulationsForUser()

        editdeletesimulationcontentdiv.Visible = False


    End Sub

    Protected Sub DeleteInjuryBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DeleteInjuryBtn.Click
        DBConnection.DELETE_INJURY(ViewState.Item(currentInjuryID))

        LoadInjuriesForUser()

        editdeleteinjurycontentdiv.Visible = False

    End Sub

    Protected Sub DeleteTrainingBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DeleteTrainingBtn.Click
        DBConnection.DELETE_TRAINING(ViewState.Item(currentTrainingID))

        LoadTrainingsForUser()

        editdeletetrainingcontentdiv.Visible = False

    End Sub

    Protected Sub DeletePlayerBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DeletePlayerBtn.Click
        DBConnection.DELETE_PLAYER(ViewState.Item(currentPlayerID))

        LoadPlayersForUser()

        editdeleteplayercontentdiv.Visible = False

    End Sub

#End Region


#Region "TRAINing Radio Buttons"

    Private Sub UpdateTrainingForSimulation(ByVal sender As RadioButton, ByVal training As Integer, ByVal season As String)
        trainingsIDCol = ViewState.Item(trainingsIDColKey)
        Dim value As Integer = -1

        If (sender.Checked = True) Then
            value = CType(trainingsIDCol.Item(training), Base).ID

        End If

        CType(GetSimulationByID(ViewState.Item(currentSimulationID)).Setup, SimulationSetup).TrainingMap.Item(season) = value


    End Sub

    Protected Sub Training1Season1_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training1Season1.CheckedChanged
        UpdateTrainingForSimulation(sender, 1, Cons.SEASON1)
    End Sub
    Protected Sub Training1Season2_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training1Season2.CheckedChanged

        UpdateTrainingForSimulation(sender, 1, Cons.SEASON2)
    End Sub
    Protected Sub Training1Season3_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training1Season3.CheckedChanged
        UpdateTrainingForSimulation(sender, 1, Cons.SEASON3)
    End Sub
    Protected Sub Training1Season4_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training1Season4.CheckedChanged
        UpdateTrainingForSimulation(sender, 1, Cons.SEASON4)
    End Sub
    Protected Sub Training1Season5_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training1Season5.CheckedChanged
        UpdateTrainingForSimulation(sender, 1, Cons.SEASON5)
    End Sub
    Protected Sub Training1Season6_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training1Season6.CheckedChanged
        UpdateTrainingForSimulation(sender, 1, Cons.SEASON6)
    End Sub
    Protected Sub Training1Season7_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training1Season7.CheckedChanged
        UpdateTrainingForSimulation(sender, 1, Cons.SEASON7)
    End Sub
    Protected Sub Training1Season8_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training1Season8.CheckedChanged
        UpdateTrainingForSimulation(sender, 1, Cons.SEASON8)
    End Sub
    Protected Sub Training1Season9_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training1Season9.CheckedChanged
        UpdateTrainingForSimulation(sender, 1, Cons.SEASON9)
    End Sub
    Protected Sub Training1Season10_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training1Season10.CheckedChanged
        UpdateTrainingForSimulation(sender, 1, Cons.SEASON10)
    End Sub
    Protected Sub Training1Season11_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training1Season11.CheckedChanged
        UpdateTrainingForSimulation(sender, 1, Cons.SEASON11)
    End Sub
    Protected Sub Training1Season12_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training1Season12.CheckedChanged
        UpdateTrainingForSimulation(sender, 1, Cons.SEASON12)
    End Sub
    Protected Sub Training1Season13_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training1Season13.CheckedChanged
        UpdateTrainingForSimulation(sender, 1, Cons.SEASON13)
    End Sub
    Protected Sub Training1Season14_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training1Season14.CheckedChanged
        UpdateTrainingForSimulation(sender, 1, Cons.SEASON14)
    End Sub
    Protected Sub Training1Season15_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training1Season15.CheckedChanged
        UpdateTrainingForSimulation(sender, 1, Cons.SEASON15)
    End Sub





    Protected Sub Training2Season1_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training2Season1.CheckedChanged
        UpdateTrainingForSimulation(sender, 2, Cons.SEASON1)
    End Sub
    Protected Sub Training2Season2_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training2Season2.CheckedChanged
        UpdateTrainingForSimulation(sender, 2, Cons.SEASON2)
    End Sub
    Protected Sub Training2Season3_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training2Season3.CheckedChanged
        UpdateTrainingForSimulation(sender, 2, Cons.SEASON3)
    End Sub
    Protected Sub Training2Season4_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training2Season4.CheckedChanged
        UpdateTrainingForSimulation(sender, 2, Cons.SEASON4)
    End Sub
    Protected Sub Training2Season5_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training2Season5.CheckedChanged
        UpdateTrainingForSimulation(sender, 2, Cons.SEASON5)
    End Sub
    Protected Sub Training2Season6_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training2Season6.CheckedChanged
        UpdateTrainingForSimulation(sender, 2, Cons.SEASON6)
    End Sub
    Protected Sub Training2Season7_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training2Season7.CheckedChanged
        UpdateTrainingForSimulation(sender, 2, Cons.SEASON7)
    End Sub
    Protected Sub Training2Season8_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training2Season8.CheckedChanged
        UpdateTrainingForSimulation(sender, 2, Cons.SEASON8)
    End Sub
    Protected Sub Training2Season9_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training2Season9.CheckedChanged
        UpdateTrainingForSimulation(sender, 2, Cons.SEASON9)
    End Sub
    Protected Sub Training2Season10_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training2Season10.CheckedChanged
        UpdateTrainingForSimulation(sender, 2, Cons.SEASON10)
    End Sub
    Protected Sub Training2Season11_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training2Season11.CheckedChanged
        UpdateTrainingForSimulation(sender, 2, Cons.SEASON11)
    End Sub
    Protected Sub Training2Season12_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training2Season12.CheckedChanged
        UpdateTrainingForSimulation(sender, 2, Cons.SEASON12)
    End Sub
    Protected Sub Training2Season13_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training2Season13.CheckedChanged
        UpdateTrainingForSimulation(sender, 2, Cons.SEASON13)
    End Sub
    Protected Sub Training2Season14_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training2Season14.CheckedChanged
        UpdateTrainingForSimulation(sender, 2, Cons.SEASON14)
    End Sub
    Protected Sub Training2Season15_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training2Season15.CheckedChanged
        UpdateTrainingForSimulation(sender, 2, Cons.SEASON15)
    End Sub




    Protected Sub Training3Season1_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training3Season1.CheckedChanged
        UpdateTrainingForSimulation(sender, 3, Cons.SEASON1)
    End Sub
    Protected Sub Training3Season2_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training3Season2.CheckedChanged
        UpdateTrainingForSimulation(sender, 3, Cons.SEASON2)
    End Sub
    Protected Sub Training3Season3_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training3Season3.CheckedChanged
        UpdateTrainingForSimulation(sender, 3, Cons.SEASON3)
    End Sub
    Protected Sub Training3Season4_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training3Season4.CheckedChanged
        UpdateTrainingForSimulation(sender, 3, Cons.SEASON4)
    End Sub
    Protected Sub Training3Season5_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training3Season5.CheckedChanged
        UpdateTrainingForSimulation(sender, 3, Cons.SEASON5)
    End Sub
    Protected Sub Training3Season6_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training3Season6.CheckedChanged
        UpdateTrainingForSimulation(sender, 3, Cons.SEASON6)
    End Sub
    Protected Sub Training3Season7_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training3Season7.CheckedChanged
        UpdateTrainingForSimulation(sender, 3, Cons.SEASON7)
    End Sub
    Protected Sub Training3Season8_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training3Season8.CheckedChanged
        UpdateTrainingForSimulation(sender, 3, Cons.SEASON8)
    End Sub
    Protected Sub Training3Season9_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training3Season9.CheckedChanged
        UpdateTrainingForSimulation(sender, 3, Cons.SEASON9)
    End Sub
    Protected Sub Training3Season10_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training3Season10.CheckedChanged
        UpdateTrainingForSimulation(sender, 3, Cons.SEASON10)
    End Sub
    Protected Sub Training3Season11_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training3Season11.CheckedChanged
        UpdateTrainingForSimulation(sender, 3, Cons.SEASON11)
    End Sub
    Protected Sub Training3Season12_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training3Season12.CheckedChanged
        UpdateTrainingForSimulation(sender, 3, Cons.SEASON12)
    End Sub
    Protected Sub Training3Season13_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training3Season13.CheckedChanged
        UpdateTrainingForSimulation(sender, 3, Cons.SEASON13)
    End Sub
    Protected Sub Training3Season14_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training3Season14.CheckedChanged
        UpdateTrainingForSimulation(sender, 3, Cons.SEASON14)
    End Sub
    Protected Sub Training3Season15_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training3Season15.CheckedChanged
        UpdateTrainingForSimulation(sender, 3, Cons.SEASON15)
    End Sub



    Protected Sub Training4Season1_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training4Season1.CheckedChanged
        UpdateTrainingForSimulation(sender, 4, Cons.SEASON1)
    End Sub
    Protected Sub Training4Season2_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training4Season2.CheckedChanged
        UpdateTrainingForSimulation(sender, 4, Cons.SEASON2)
    End Sub
    Protected Sub Training4Season3_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training4Season3.CheckedChanged
        UpdateTrainingForSimulation(sender, 4, Cons.SEASON3)
    End Sub
    Protected Sub Training4Season4_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training4Season4.CheckedChanged
        UpdateTrainingForSimulation(sender, 4, Cons.SEASON4)
    End Sub
    Protected Sub Training4Season5_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training4Season5.CheckedChanged
        UpdateTrainingForSimulation(sender, 4, Cons.SEASON5)
    End Sub
    Protected Sub Training4Season6_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training4Season6.CheckedChanged
        UpdateTrainingForSimulation(sender, 4, Cons.SEASON6)
    End Sub
    Protected Sub Training4Season7_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training4Season7.CheckedChanged
        UpdateTrainingForSimulation(sender, 4, Cons.SEASON7)
    End Sub
    Protected Sub Training4Season8_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training4Season8.CheckedChanged
        UpdateTrainingForSimulation(sender, 4, Cons.SEASON8)
    End Sub
    Protected Sub Training4Season9_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training4Season9.CheckedChanged
        UpdateTrainingForSimulation(sender, 4, Cons.SEASON9)
    End Sub
    Protected Sub Training4Season10_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training4Season10.CheckedChanged
        UpdateTrainingForSimulation(sender, 4, Cons.SEASON10)
    End Sub
    Protected Sub Training4Season11_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training4Season11.CheckedChanged
        UpdateTrainingForSimulation(sender, 4, Cons.SEASON11)
    End Sub
    Protected Sub Training4Season12_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training4Season12.CheckedChanged
        UpdateTrainingForSimulation(sender, 4, Cons.SEASON12)
    End Sub
    Protected Sub Training4Season13_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training4Season13.CheckedChanged
        UpdateTrainingForSimulation(sender, 4, Cons.SEASON13)
    End Sub
    Protected Sub Training4Season14_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training4Season14.CheckedChanged
        UpdateTrainingForSimulation(sender, 4, Cons.SEASON14)
    End Sub
    Protected Sub Training4Season15_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training4Season15.CheckedChanged
        UpdateTrainingForSimulation(sender, 4, Cons.SEASON15)
    End Sub


    Protected Sub Training5Season1_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training5Season1.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON1)
    End Sub
    Protected Sub Training5Season2_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training5Season2.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON2)
    End Sub
    Protected Sub Training5Season3_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training5Season3.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON3)
    End Sub
    Protected Sub Training5Season4_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training5Season4.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON4)
    End Sub
    Protected Sub Training5Season5_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training5Season5.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON5)
    End Sub
    Protected Sub Training5Season6_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training5Season6.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON6)
    End Sub
    Protected Sub Training5Season7_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training5Season7.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON7)
    End Sub
    Protected Sub Training5Season8_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training5Season8.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON8)
    End Sub
    Protected Sub Training5Season9_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training5Season9.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON9)
    End Sub
    Protected Sub Training5Season10_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training5Season10.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON10)
    End Sub
    Protected Sub Training5Season11_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training5Season11.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON11)
    End Sub
    Protected Sub Training5Season12_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training5Season12.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON12)
    End Sub
    Protected Sub Training5Season13_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training5Season13.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON13)
    End Sub
    Protected Sub Training5Season14_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training5Season14.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON14)
    End Sub
    Protected Sub Training5Season15_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training5Season15.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON15)
    End Sub


    Protected Sub Training6Season1_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training6Season1.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON1)
    End Sub
    Protected Sub Training6Season2_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training6Season2.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON2)
    End Sub
    Protected Sub Training6Season3_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training6Season3.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON3)
    End Sub
    Protected Sub Training6Season4_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training6Season4.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON4)
    End Sub
    Protected Sub Training6Season5_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training6Season5.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON5)
    End Sub
    Protected Sub Training6Season6_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training6Season6.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON6)
    End Sub
    Protected Sub Training6Season7_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training6Season7.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON7)
    End Sub
    Protected Sub Training6Season8_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training6Season8.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON8)
    End Sub
    Protected Sub Training6Season9_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training6Season9.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON9)
    End Sub
    Protected Sub Training6Season10_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training6Season10.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON10)
    End Sub
    Protected Sub Training6Season11_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training6Season11.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON11)
    End Sub
    Protected Sub Training6Season12_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training6Season12.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON12)
    End Sub
    Protected Sub Training6Season13_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training6Season13.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON13)
    End Sub
    Protected Sub Training6Season14_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training6Season14.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON14)
    End Sub
    Protected Sub Training6Season15_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training6Season15.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON15)
    End Sub

    Protected Sub Training7Season1_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training7Season1.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON1)
    End Sub
    Protected Sub Training7Season2_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training7Season2.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON2)
    End Sub
    Protected Sub Training7Season3_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training7Season3.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON3)
    End Sub
    Protected Sub Training7Season4_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training7Season4.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON4)
    End Sub
    Protected Sub Training7Season5_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training7Season5.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON5)
    End Sub
    Protected Sub Training7Season6_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training7Season6.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON6)
    End Sub
    Protected Sub Training7Season7_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training7Season7.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON7)
    End Sub
    Protected Sub Training7Season8_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training7Season8.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON8)
    End Sub
    Protected Sub Training7Season9_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training7Season9.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON9)
    End Sub
    Protected Sub Training7Season10_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training7Season10.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON10)
    End Sub
    Protected Sub Training7Season11_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training7Season11.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON11)
    End Sub
    Protected Sub Training7Season12_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training7Season12.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON12)
    End Sub
    Protected Sub Training7Season13_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training7Season13.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON13)
    End Sub
    Protected Sub Training7Season14_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training7Season14.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON14)
    End Sub
    Protected Sub Training7Season15_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training7Season15.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON15)
    End Sub


    Protected Sub Training8Season1_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training8Season1.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON1)
    End Sub
    Protected Sub Training8Season2_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training8Season2.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON2)
    End Sub
    Protected Sub Training8Season3_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training8Season3.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON3)
    End Sub
    Protected Sub Training8Season4_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training8Season4.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON4)
    End Sub
    Protected Sub Training8Season5_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training8Season5.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON5)
    End Sub
    Protected Sub Training8Season6_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training8Season6.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON6)
    End Sub
    Protected Sub Training8Season7_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training8Season7.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON7)
    End Sub
    Protected Sub Training8Season8_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training8Season8.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON8)
    End Sub
    Protected Sub Training8Season9_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training8Season9.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON9)
    End Sub
    Protected Sub Training8Season10_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training8Season10.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON10)
    End Sub
    Protected Sub Training8Season11_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training8Season11.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON11)
    End Sub
    Protected Sub Training8Season12_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training8Season12.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON12)
    End Sub
    Protected Sub Training8Season13_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training8Season13.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON13)
    End Sub
    Protected Sub Training8Season14_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training8Season14.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON14)
    End Sub
    Protected Sub Training8Season15_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training8Season15.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON15)
    End Sub


    Protected Sub Training9Season1_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training9Season1.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON1)
    End Sub
    Protected Sub Training9Season2_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training9Season2.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON2)
    End Sub
    Protected Sub Training9Season3_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training9Season3.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON3)
    End Sub
    Protected Sub Training9Season4_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training9Season4.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON4)
    End Sub
    Protected Sub Training9Season5_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training9Season5.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON5)
    End Sub
    Protected Sub Training9Season6_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training9Season6.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON6)
    End Sub
    Protected Sub Training9Season7_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training9Season7.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON7)
    End Sub
    Protected Sub Training9Season8_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training9Season8.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON8)
    End Sub
    Protected Sub Training9Season9_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training9Season9.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON9)
    End Sub
    Protected Sub Training9Season10_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training9Season10.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON10)
    End Sub
    Protected Sub Training9Season11_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training9Season11.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON11)
    End Sub
    Protected Sub Training9Season12_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training9Season12.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON12)
    End Sub
    Protected Sub Training9Season13_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training9Season13.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON13)
    End Sub
    Protected Sub Training9Season14_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training9Season14.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON14)
    End Sub
    Protected Sub Training9Season15_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training9Season15.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON15)
    End Sub


    Protected Sub Training10Season1_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training10Season1.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON1)
    End Sub
    Protected Sub Training10Season2_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training10Season2.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON2)
    End Sub
    Protected Sub Training10Season3_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training10Season3.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON3)
    End Sub
    Protected Sub Training10Season4_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training10Season4.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON4)
    End Sub
    Protected Sub Training10Season5_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training10Season5.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON5)
    End Sub
    Protected Sub Training10Season6_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training10Season6.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON6)
    End Sub
    Protected Sub Training10Season7_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training10Season7.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON7)
    End Sub
    Protected Sub Training10Season8_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training10Season8.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON8)
    End Sub
    Protected Sub Training10Season9_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training10Season9.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON9)
    End Sub
    Protected Sub Training10Season10_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training10Season10.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON10)
    End Sub
    Protected Sub Training10Season11_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training10Season11.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON11)
    End Sub
    Protected Sub Training10Season12_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training10Season12.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON12)
    End Sub
    Protected Sub Training10Season13_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training10Season13.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON13)
    End Sub
    Protected Sub Training10Season14_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training10Season14.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON14)
    End Sub
    Protected Sub Training10Season15_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training10Season15.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON15)
    End Sub

    Protected Sub Training11Season1_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training11Season1.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON1)
    End Sub
    Protected Sub Training11Season2_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training11Season2.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON2)
    End Sub
    Protected Sub Training11Season3_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training11Season3.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON3)
    End Sub
    Protected Sub Training11Season4_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training11Season4.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON4)
    End Sub
    Protected Sub Training11Season5_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training11Season5.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON5)
    End Sub
    Protected Sub Training11Season6_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training11Season6.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON6)
    End Sub
    Protected Sub Training11Season7_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training11Season7.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON7)
    End Sub
    Protected Sub Training11Season8_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training11Season8.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON8)
    End Sub
    Protected Sub Training11Season9_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training11Season9.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON9)
    End Sub
    Protected Sub Training11Season10_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training11Season10.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON10)
    End Sub
    Protected Sub Training11Season11_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training11Season11.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON11)
    End Sub
    Protected Sub Training11Season12_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training11Season12.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON12)
    End Sub
    Protected Sub Training11Season13_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training11Season13.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON13)
    End Sub
    Protected Sub Training11Season14_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training11Season14.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON14)
    End Sub
    Protected Sub Training11Season15_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training11Season15.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON15)
    End Sub


    Protected Sub Training12Season1_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training12Season1.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON1)
    End Sub
    Protected Sub Training12Season2_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training12Season2.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON2)
    End Sub
    Protected Sub Training12Season3_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training12Season3.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON3)
    End Sub
    Protected Sub Training12Season4_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training12Season4.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON4)
    End Sub
    Protected Sub Training12Season5_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training12Season5.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON5)
    End Sub
    Protected Sub Training12Season6_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training12Season6.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON6)
    End Sub
    Protected Sub Training12Season7_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training12Season7.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON7)
    End Sub
    Protected Sub Training12Season8_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training12Season8.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON8)
    End Sub
    Protected Sub Training12Season9_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training12Season9.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON9)
    End Sub
    Protected Sub Training12Season10_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training12Season10.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON10)
    End Sub
    Protected Sub Training12Season11_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training12Season11.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON11)
    End Sub
    Protected Sub Training12Season12_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training12Season12.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON12)
    End Sub
    Protected Sub Training12Season13_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training12Season13.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON13)
    End Sub
    Protected Sub Training12Season14_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training12Season14.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON14)
    End Sub
    Protected Sub Training12Season15_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training12Season15.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON15)
    End Sub


    Protected Sub Training13Season1_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training13Season1.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON1)
    End Sub
    Protected Sub Training13Season2_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training13Season2.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON2)
    End Sub
    Protected Sub Training13Season3_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training13Season3.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON3)
    End Sub
    Protected Sub Training13Season4_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training13Season4.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON4)
    End Sub
    Protected Sub Training13Season5_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training13Season5.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON5)
    End Sub
    Protected Sub Training13Season6_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training13Season6.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON6)
    End Sub
    Protected Sub Training13Season7_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training13Season7.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON7)
    End Sub
    Protected Sub Training13Season8_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training13Season8.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON8)
    End Sub
    Protected Sub Training13Season9_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training13Season9.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON9)
    End Sub
    Protected Sub Training13Season10_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training13Season10.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON10)
    End Sub
    Protected Sub Training13Season11_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training13Season11.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON11)
    End Sub
    Protected Sub Training13Season12_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training13Season12.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON12)
    End Sub
    Protected Sub Training13Season13_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training13Season13.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON13)
    End Sub
    Protected Sub Training13Season14_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training13Season14.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON14)
    End Sub
    Protected Sub Training13Season15_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training13Season15.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON15)
    End Sub


    Protected Sub Training14Season1_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training14Season1.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON1)
    End Sub
    Protected Sub Training14Season2_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training14Season2.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON2)
    End Sub
    Protected Sub Training14Season3_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training14Season3.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON3)
    End Sub
    Protected Sub Training14Season4_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training14Season4.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON4)
    End Sub
    Protected Sub Training14Season5_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training14Season5.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON5)
    End Sub
    Protected Sub Training14Season6_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training14Season6.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON6)
    End Sub
    Protected Sub Training14Season7_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training14Season7.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON7)
    End Sub
    Protected Sub Training14Season8_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training14Season8.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON8)
    End Sub
    Protected Sub Training14Season9_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training14Season9.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON9)
    End Sub
    Protected Sub Training14Season10_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training14Season10.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON10)
    End Sub
    Protected Sub Training14Season11_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training14Season11.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON11)
    End Sub
    Protected Sub Training14Season12_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training14Season12.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON12)
    End Sub
    Protected Sub Training14Season13_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training14Season13.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON13)
    End Sub
    Protected Sub Training14Season14_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training14Season14.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON14)
    End Sub
    Protected Sub Training14Season15_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training14Season15.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON15)
    End Sub


    Protected Sub Training15Season1_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training15Season1.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON1)
    End Sub
    Protected Sub Training15Season2_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training15Season2.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON2)
    End Sub
    Protected Sub Training15Season3_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training15Season3.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON3)
    End Sub
    Protected Sub Training15Season4_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training15Season4.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON4)
    End Sub
    Protected Sub Training15Season5_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training15Season5.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON5)
    End Sub
    Protected Sub Training15Season6_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training15Season6.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON6)
    End Sub
    Protected Sub Training15Season7_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training15Season7.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON7)
    End Sub
    Protected Sub Training15Season8_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training15Season8.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON8)
    End Sub
    Protected Sub Training15Season9_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training15Season9.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON9)
    End Sub
    Protected Sub Training15Season10_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training15Season10.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON10)
    End Sub
    Protected Sub Training15Season11_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training15Season11.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON11)
    End Sub
    Protected Sub Training15Season12_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training15Season12.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON12)
    End Sub
    Protected Sub Training15Season13_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training15Season13.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON13)
    End Sub
    Protected Sub Training15Season14_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training15Season14.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON14)
    End Sub
    Protected Sub Training15Season15_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training15Season15.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON15)
    End Sub


    Protected Sub Training16Season1_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training16Season1.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON1)
    End Sub
    Protected Sub Training16Season2_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training16Season2.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON2)
    End Sub
    Protected Sub Training16Season3_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training16Season3.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON3)
    End Sub
    Protected Sub Training16Season4_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training16Season4.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON4)
    End Sub
    Protected Sub Training16Season5_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training16Season5.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON5)
    End Sub
    Protected Sub Training16Season6_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training16Season6.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON6)
    End Sub
    Protected Sub Training16Season7_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training16Season7.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON7)
    End Sub
    Protected Sub Training16Season8_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training16Season8.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON8)
    End Sub
    Protected Sub Training16Season9_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training16Season9.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON9)
    End Sub
    Protected Sub Training16Season10_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training16Season10.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON10)
    End Sub
    Protected Sub Training16Season11_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training16Season11.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON11)
    End Sub
    Protected Sub Training16Season12_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training16Season12.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON12)
    End Sub
    Protected Sub Training16Season13_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training16Season13.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON13)
    End Sub
    Protected Sub Training16Season14_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training16Season14.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON14)
    End Sub
    Protected Sub Training16Season15_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training16Season15.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON15)
    End Sub


    Protected Sub Training17Season1_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training17Season1.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON1)
    End Sub
    Protected Sub Training17Season2_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training17Season2.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON2)
    End Sub
    Protected Sub Training17Season3_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training17Season3.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON3)
    End Sub
    Protected Sub Training17Season4_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training17Season4.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON4)
    End Sub
    Protected Sub Training17Season5_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training17Season5.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON5)
    End Sub
    Protected Sub Training17Season6_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training17Season6.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON6)
    End Sub
    Protected Sub Training17Season7_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training17Season7.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON7)
    End Sub
    Protected Sub Training17Season8_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training17Season8.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON8)
    End Sub
    Protected Sub Training17Season9_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training17Season9.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON9)
    End Sub
    Protected Sub Training17Season10_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training17Season10.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON10)
    End Sub
    Protected Sub Training17Season11_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training17Season11.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON11)
    End Sub
    Protected Sub Training17Season12_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training17Season12.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON12)
    End Sub
    Protected Sub Training17Season13_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training17Season13.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON13)
    End Sub
    Protected Sub Training17Season14_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training17Season14.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON14)
    End Sub
    Protected Sub Training17Season15_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training17Season15.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON15)
    End Sub


    Protected Sub Training18Season1_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training18Season1.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON1)
    End Sub
    Protected Sub Training18Season2_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training18Season2.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON2)
    End Sub
    Protected Sub Training18Season3_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training18Season3.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON3)
    End Sub
    Protected Sub Training18Season4_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training18Season4.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON4)
    End Sub
    Protected Sub Training18Season5_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training18Season5.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON5)
    End Sub
    Protected Sub Training18Season6_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training18Season6.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON6)
    End Sub
    Protected Sub Training18Season7_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training18Season7.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON7)
    End Sub
    Protected Sub Training18Season8_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training18Season8.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON8)
    End Sub
    Protected Sub Training18Season9_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training18Season9.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON9)
    End Sub
    Protected Sub Training18Season10_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training18Season10.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON10)
    End Sub
    Protected Sub Training18Season11_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training18Season11.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON11)
    End Sub
    Protected Sub Training18Season12_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training18Season12.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON12)
    End Sub
    Protected Sub Training18Season13_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training18Season13.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON13)
    End Sub
    Protected Sub Training18Season14_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training18Season14.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON14)
    End Sub
    Protected Sub Training18Season15_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training18Season15.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON15)
    End Sub


    Protected Sub Training19Season1_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training19Season1.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON1)
    End Sub
    Protected Sub Training19Season2_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training19Season2.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON2)
    End Sub
    Protected Sub Training19Season3_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training19Season3.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON3)
    End Sub
    Protected Sub Training19Season4_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training19Season4.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON4)
    End Sub
    Protected Sub Training19Season5_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training19Season5.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON5)
    End Sub
    Protected Sub Training19Season6_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training19Season6.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON6)
    End Sub
    Protected Sub Training19Season7_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training19Season7.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON7)
    End Sub
    Protected Sub Training19Season8_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training19Season8.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON8)
    End Sub
    Protected Sub Training19Season9_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training19Season9.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON9)
    End Sub
    Protected Sub Training19Season10_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training19Season10.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON10)
    End Sub
    Protected Sub Training19Season11_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training19Season11.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON11)
    End Sub
    Protected Sub Training19Season12_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training19Season12.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON12)
    End Sub
    Protected Sub Training19Season13_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training19Season13.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON13)
    End Sub
    Protected Sub Training19Season14_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training19Season14.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON14)
    End Sub
    Protected Sub Training19Season15_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training19Season15.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON15)
    End Sub


    Protected Sub Training20Season1_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training20Season1.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON1)
    End Sub
    Protected Sub Training20Season2_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training20Season2.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON2)
    End Sub
    Protected Sub Training20Season3_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training20Season3.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON3)
    End Sub
    Protected Sub Training20Season4_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training20Season4.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON4)
    End Sub
    Protected Sub Training20Season5_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training20Season5.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON5)
    End Sub
    Protected Sub Training20Season6_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training20Season6.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON6)
    End Sub
    Protected Sub Training20Season7_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training20Season7.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON7)
    End Sub
    Protected Sub Training20Season8_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training20Season8.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON8)
    End Sub
    Protected Sub Training20Season9_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training20Season9.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON9)
    End Sub
    Protected Sub Training20Season10_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training20Season10.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON10)
    End Sub
    Protected Sub Training20Season11_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training20Season11.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON11)
    End Sub
    Protected Sub Training20Season12_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training20Season12.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON12)
    End Sub
    Protected Sub Training20Season13_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training20Season13.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON13)
    End Sub
    Protected Sub Training20Season14_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training20Season14.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON14)
    End Sub
    Protected Sub Training20Season15_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Training20Season15.CheckedChanged
        UpdateTrainingForSimulation(sender, 5, Cons.SEASON15)
    End Sub


#End Region


#Region "new injury age ranges"


    Protected Sub RecoveryWeeksTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RecoveryWeeksTxtB.TextChanged

        Dim value As Integer = CleanInteger(sender.Text)
        CType(GetInjuryByID(ViewState.Item(currentInjuryID)).Setup, InjurySetup).RecoveryWeeks = value
    End Sub

    Private Sub UpdateRecovery(ByVal sender As TextBox, ByVal key As String)

        Dim value As Integer = CleanInteger(sender.Text)

        CType(GetInjuryByID(ViewState.Item(currentInjuryID)).Setup, InjurySetup).RecoveryAgeMap.Item(key) = value

    End Sub

    Protected Sub RecoveryAge1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RecoveryAge1.TextChanged
        UpdateRecovery(sender, Cons.AGERANGE1)
    End Sub

    Protected Sub RecoveryAge2_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RecoveryAge2.TextChanged
        UpdateRecovery(sender, Cons.AGERANGE2)
    End Sub

    Protected Sub RecoveryAge3_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RecoveryAge3.TextChanged
        UpdateRecovery(sender, Cons.AGERANGE3)
    End Sub

    Protected Sub RecoveryAge4_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RecoveryAge4.TextChanged
        UpdateRecovery(sender, Cons.AGERANGE4)
    End Sub

    Protected Sub RecoveryAge5_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RecoveryAge5.TextChanged
        UpdateRecovery(sender, Cons.AGERANGE5)
    End Sub

    Protected Sub RecoveryAge6_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RecoveryAge6.TextChanged
        UpdateRecovery(sender, Cons.AGERANGE6)
    End Sub

    Protected Sub RecoveryAge7_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RecoveryAge7.TextChanged
        UpdateRecovery(sender, Cons.AGERANGE7)
    End Sub

#End Region


#Region "training age ranges"

    Private Sub UpdateTrainingAges(ByVal sender As TextBox, ByVal key As String)

        Dim value As Double = CleanDouble(sender.Text)

        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).TrainingAgeMap.Item(key) = value

    End Sub

    Protected Sub TrainingAgeRange1TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TrainingAgeRange1TxtB.TextChanged
        UpdateTrainingAges(sender, Cons.AGERANGE1)
    End Sub

    Protected Sub TrainingAgeRange2TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TrainingAgeRange2TxtB.TextChanged
        UpdateTrainingAges(sender, Cons.AGERANGE2)
    End Sub

    Protected Sub TrainingAgeRange3TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TrainingAgeRange3TxtB.TextChanged
        UpdateTrainingAges(sender, Cons.AGERANGE3)
    End Sub

    Protected Sub TrainingAgeRange4TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TrainingAgeRange4TxtB.TextChanged
        UpdateTrainingAges(sender, Cons.AGERANGE4)
    End Sub

    Protected Sub TrainingAgeRange5TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TrainingAgeRange5TxtB.TextChanged
        UpdateTrainingAges(sender, Cons.AGERANGE5)
    End Sub

    Protected Sub TrainingAgeRange6TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TrainingAgeRange6TxtB.TextChanged
        UpdateTrainingAges(sender, Cons.AGERANGE6)
    End Sub

    Protected Sub TrainingAgeRange7TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TrainingAgeRange7TxtB.TextChanged
        UpdateTrainingAges(sender, Cons.AGERANGE7)
    End Sub


#End Region


#Region "Player Stats Change"


    Private Sub InjuryTypeCombox_SelectionChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles InjuryTypeCombox.SelectedIndexChanged
        Dim sel As String = CType(sender, DropDownList).SelectedItem.Text

        CType(GetPlayerByID(ViewState.Item(currentPlayerID)).Setup, PlayerSetup).InjuryType = sel

        'if none, then set 0 for recovery.
        If sel.Equals(Cons.NONE) Then
            CType(GetPlayerByID(ViewState.Item(currentPlayerID)).Setup, PlayerSetup).RecoveryLeft = 0
            CType(GetPlayerByID(ViewState.Item(currentPlayerID)).Setup, PlayerSetup).InjuryTypeID = -1

        Else

            CType(GetPlayerByID(ViewState.Item(currentPlayerID)).Setup, PlayerSetup).InjuryTypeID = GetInjuryByName(sel).ID

        End If


    End Sub

    Protected Sub RecoveryLeftTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RecoveryLeftTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        CType(GetPlayerByID(ViewState.Item(currentPlayerID)).Setup, PlayerSetup).RecoveryLeft = value
    End Sub



    Protected Sub AgeTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles AgeTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        CType(GetPlayerByID(ViewState.Item(currentPlayerID)).Setup, PlayerSetup).Age = value
    End Sub
    Protected Sub NumberTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles NumberTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        CType(GetPlayerByID(ViewState.Item(currentPlayerID)).Setup, PlayerSetup).Number = value
    End Sub

    Private Sub RetireRangeCombox_SelectionChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RetireRangeCombox.SelectedIndexChanged
        Dim sel As String = CType(sender, DropDownList).SelectedItem.Text

        CType(GetPlayerByID(ViewState.Item(currentPlayerID)).Setup, PlayerSetup).RetireRange = sel


    End Sub

    Private Sub PositionCombox_SelectionChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PositionCombox.SelectedIndexChanged
        Dim sel As String = CType(sender, DropDownList).SelectedItem.Text

        CType(GetPlayerByID(ViewState.Item(currentPlayerID)).Setup, PlayerSetup).Position = sel

    End Sub



    Protected Sub CrossingTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles CrossingTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        CType(GetPlayerByID(ViewState.Item(currentPlayerID)).Setup, PlayerSetup).Crossing = value
    End Sub

    Protected Sub FinishingTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles FinishingTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        CType(GetPlayerByID(ViewState.Item(currentPlayerID)).Setup, PlayerSetup).Finishing = value
    End Sub

    Protected Sub HeadingTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles HeadingTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        CType(GetPlayerByID(ViewState.Item(currentPlayerID)).Setup, PlayerSetup).Heading = value
    End Sub

    Protected Sub ShortPassTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ShortPassTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        CType(GetPlayerByID(ViewState.Item(currentPlayerID)).Setup, PlayerSetup).Short_pass = value
    End Sub

    Protected Sub VolleysTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles VolleysTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        CType(GetPlayerByID(ViewState.Item(currentPlayerID)).Setup, PlayerSetup).Volleys = value
    End Sub



    Protected Sub ShotPowerTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ShotPowerTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        CType(GetPlayerByID(ViewState.Item(currentPlayerID)).Setup, PlayerSetup).Shot_power = value
    End Sub

    Protected Sub JumpingTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles JumpingTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        CType(GetPlayerByID(ViewState.Item(currentPlayerID)).Setup, PlayerSetup).Jumping = value
    End Sub

    Protected Sub StaminaTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles StaminaTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        CType(GetPlayerByID(ViewState.Item(currentPlayerID)).Setup, PlayerSetup).Stamina = value
    End Sub

    Protected Sub StrengthTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles StrengthTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        CType(GetPlayerByID(ViewState.Item(currentPlayerID)).Setup, PlayerSetup).Strength = value
    End Sub

    Protected Sub LongShotsTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles LongShotsTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        CType(GetPlayerByID(ViewState.Item(currentPlayerID)).Setup, PlayerSetup).Long_shot = value
    End Sub



    Protected Sub AggressionTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles AggressionTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        CType(GetPlayerByID(ViewState.Item(currentPlayerID)).Setup, PlayerSetup).Aggression = value
    End Sub

    Protected Sub TactAwareTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TactAwareTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        CType(GetPlayerByID(ViewState.Item(currentPlayerID)).Setup, PlayerSetup).Tactical_awareness = value
    End Sub
    Protected Sub PositioningTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles PositioningTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        CType(GetPlayerByID(ViewState.Item(currentPlayerID)).Setup, PlayerSetup).Positioning = value
    End Sub
    Protected Sub PenaltiesTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles PenaltiesTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        CType(GetPlayerByID(ViewState.Item(currentPlayerID)).Setup, PlayerSetup).Penalties = value
    End Sub
    Protected Sub VisionTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles VisionTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        CType(GetPlayerByID(ViewState.Item(currentPlayerID)).Setup, PlayerSetup).Vision = value
    End Sub


    Protected Sub BallControlTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles BallControlTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        CType(GetPlayerByID(ViewState.Item(currentPlayerID)).Setup, PlayerSetup).BallControl = value
    End Sub
    Protected Sub CurveTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles CurveTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        CType(GetPlayerByID(ViewState.Item(currentPlayerID)).Setup, PlayerSetup).Curve = value
    End Sub
    Protected Sub DribblingTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DribblingTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        CType(GetPlayerByID(ViewState.Item(currentPlayerID)).Setup, PlayerSetup).Dribbling = value
    End Sub
    Protected Sub FreeKickAccTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles FreeKickAccTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        CType(GetPlayerByID(ViewState.Item(currentPlayerID)).Setup, PlayerSetup).Freekick = value
    End Sub
    Protected Sub LongPassTXtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles LongPassTXtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        CType(GetPlayerByID(ViewState.Item(currentPlayerID)).Setup, PlayerSetup).Long_pass = value
    End Sub



    Protected Sub AccelerationTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles AccelerationTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        CType(GetPlayerByID(ViewState.Item(currentPlayerID)).Setup, PlayerSetup).Acceleration = value
    End Sub
    Protected Sub AgilityTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles AgilityTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        CType(GetPlayerByID(ViewState.Item(currentPlayerID)).Setup, PlayerSetup).Agility = value
    End Sub
    Protected Sub BalanceTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles BalanceTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        CType(GetPlayerByID(ViewState.Item(currentPlayerID)).Setup, PlayerSetup).Balance = value
    End Sub
    Protected Sub ReactionsTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ReactionsTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        CType(GetPlayerByID(ViewState.Item(currentPlayerID)).Setup, PlayerSetup).Reactions = value
    End Sub
    Protected Sub SprintTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles SprintTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        CType(GetPlayerByID(ViewState.Item(currentPlayerID)).Setup, PlayerSetup).Sprint = value
    End Sub


    Protected Sub MarkingTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles MarkingTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        CType(GetPlayerByID(ViewState.Item(currentPlayerID)).Setup, PlayerSetup).Marking = value
    End Sub
    Protected Sub SlideTackleTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles SlideTackleTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        CType(GetPlayerByID(ViewState.Item(currentPlayerID)).Setup, PlayerSetup).Slide_tackle = value
    End Sub
    Protected Sub StandingTackleTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles StandingTackleTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        CType(GetPlayerByID(ViewState.Item(currentPlayerID)).Setup, PlayerSetup).Standing_tackle = value
    End Sub



    Protected Sub GKDivingTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GKDivingTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        CType(GetPlayerByID(ViewState.Item(currentPlayerID)).Setup, PlayerSetup).Diving = value
    End Sub
    Protected Sub GKHandling_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GKHandling.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        CType(GetPlayerByID(ViewState.Item(currentPlayerID)).Setup, PlayerSetup).Handling = value
    End Sub
    Protected Sub GKKicking_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GKKicking.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        CType(GetPlayerByID(ViewState.Item(currentPlayerID)).Setup, PlayerSetup).Kicking = value
    End Sub
    Protected Sub GKOneOnOneTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GKOneOnOneTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        CType(GetPlayerByID(ViewState.Item(currentPlayerID)).Setup, PlayerSetup).One_on_one = value
    End Sub
    Protected Sub GKReflexes_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GKReflexes.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        CType(GetPlayerByID(ViewState.Item(currentPlayerID)).Setup, PlayerSetup).Reflexes = value
    End Sub

#End Region

#Region "CLEANing"

    Private Function CleanDouble(ByVal val As String) As Double

        Dim cleanVal As Double

        val = val.Trim
        Try
            cleanVal = CDbl(val)
        Catch ex As Exception
            cleanVal = -1.0
        End Try
        Return cleanVal

    End Function

    Private Function CleanString(ByVal val As String) As String

        Dim cleanVal As String

        val = val.Trim
        Try
            cleanVal = CStr(val)
        Catch ex As Exception
            cleanVal = ""
        End Try
        Return cleanVal

    End Function

    Private Function CleanInteger(ByVal val As String) As Integer

        Dim cleanVal As Integer

        val = val.Trim
        Try
            cleanVal = CInt(val)
        Catch ex As Exception
            cleanVal = -1
        End Try
        Return cleanVal

    End Function


#End Region



    Private Function GetSimulationByID(ByVal id As Integer) As Base

        simulationsIDCol = ViewState.Item(simulationsIDColKey)
        For Each simul As Base In simulationsIDCol

            If (simul.ID = id) Then
                Return simul
            End If

        Next
        Return Nothing
    End Function

    Private Function GetTrainingByID(ByVal id As Integer) As Base

        trainingsIDCol = ViewState.Item(trainingsIDColKey)
        For Each training As Base In trainingsIDCol

            If (training.ID = id) Then
                Return training
            End If

        Next
        Return Nothing
    End Function

    Private Function GetInjuryByID(ByVal id As Integer) As Base

        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        For Each injury As Base In injuriesIDCol

            If (injury.ID = id) Then
                Return injury
            End If

        Next
        Return Nothing
    End Function

    Private Function GetInjuryByName(ByVal name As String) As Base

        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        For Each injury As Base In injuriesIDCol

            If (injury.Name = name) Then
                Return injury
            End If

        Next
        Return Nothing
    End Function

    Private Function GetPlayerByID(ByVal id As Integer) As Base

        playersIDCol = ViewState.Item(playersIDColKey)
        For Each player As Base In playersIDCol

            If (player.ID = id) Then
                Return player
            End If

        Next
        Return Nothing
    End Function

    Private Function GetPlayerByName(ByVal name As String) As Base

        playersIDCol = ViewState.Item(playersIDColKey)
        For Each player As Base In playersIDCol

            If (player.Name.Equals(name)) Then
                Return player
            End If

        Next
        Return Nothing
    End Function


#Region "Entering injury age ranges"

    Private Sub UpdateAgeRangeForInjury(ByVal injuryID As Integer, ByVal ageRange As String, ByVal value As Integer)

        'the simulation we are dealing with
        simulationsIDCol = ViewState.Item(simulationsIDColKey)


        Dim injuryMap As Hashtable = CType(CType(GetSimulationByID(ViewState.Item(currentSimulationID)), Base).Setup, SimulationSetup).InjuriesMap.Item(injuryID)

        If injuryMap Is Nothing Then
            Dim ageRangeMap As New Hashtable
            ageRangeMap.Add(Cons.AGERANGE1, 0)
            ageRangeMap.Add(Cons.AGERANGE2, 0)
            ageRangeMap.Add(Cons.AGERANGE3, 0)
            ageRangeMap.Add(Cons.AGERANGE4, 0)
            ageRangeMap.Add(Cons.AGERANGE5, 0)
            ageRangeMap.Add(Cons.AGERANGE6, 0)
            ageRangeMap.Add(Cons.AGERANGE7, 0)


            CType(CType(GetSimulationByID(ViewState.Item(currentSimulationID)), Base).Setup, SimulationSetup).InjuriesMap.Add(injuryID, ageRangeMap)

        End If

        CType(CType(CType(GetSimulationByID(ViewState.Item(currentSimulationID)), Base).Setup, SimulationSetup).InjuriesMap.Item(injuryID), Hashtable).Item(ageRange) = value

    End Sub

    'injury1
    Protected Sub Injury1AgeRange1TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury1AgeRange1TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(1), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE1, value)

    End Sub

    Protected Sub Injury1AgeRange2TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury1AgeRange2TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(1), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE2, value)

    End Sub

    Protected Sub Injury1AgeRange3TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury1AgeRange3TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(1), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE3, value)

    End Sub

    Protected Sub Injury1AgeRange4TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury1AgeRange4TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(1), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE4, value)

    End Sub

    Protected Sub Injury1AgeRange5TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury1AgeRange5TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(1), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE5, value)

    End Sub

    Protected Sub Injury1AgeRange6TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury1AgeRange6TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(1), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE6, value)

    End Sub

    Protected Sub Injury1AgeRange7TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury1AgeRange7TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(1), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE7, value)

    End Sub




    'injury2
    Protected Sub Injury2AgeRange1TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury2AgeRange1TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(2), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE1, value)

    End Sub

    Protected Sub Injury2AgeRange2TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury2AgeRange2TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(2), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE2, value)

    End Sub

    Protected Sub Injury2AgeRange3TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury2AgeRange3TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(2), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE3, value)

    End Sub

    Protected Sub Injury2AgeRange4TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury2AgeRange4TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(2), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE4, value)

    End Sub

    Protected Sub Injury2AgeRange5TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury2AgeRange5TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(2), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE5, value)

    End Sub

    Protected Sub Injury2AgeRange6TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury2AgeRange6TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(2), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE6, value)

    End Sub

    Protected Sub Injury2AgeRange7TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury2AgeRange7TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(2), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE7, value)

    End Sub


    'injury3
    Protected Sub Injury3AgeRange1TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury3AgeRange1TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(3), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE1, value)

    End Sub

    Protected Sub Injury3AgeRange2TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury3AgeRange2TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(3), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE2, value)

    End Sub

    Protected Sub Injury3AgeRange3TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury3AgeRange3TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(3), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE3, value)

    End Sub

    Protected Sub Injury3AgeRange4TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury3AgeRange4TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(3), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE4, value)

    End Sub

    Protected Sub Injury3AgeRange5TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury3AgeRange5TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(3), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE5, value)

    End Sub

    Protected Sub Injury3AgeRange6TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury3AgeRange6TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(3), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE6, value)

    End Sub

    Protected Sub Injury3AgeRange7TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury3AgeRange7TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(3), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE7, value)

    End Sub



    'injury4
    Protected Sub Injury4AgeRange1TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury4AgeRange1TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(4), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE1, value)

    End Sub

    Protected Sub Injury4AgeRange2TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury4AgeRange2TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(4), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE2, value)

    End Sub

    Protected Sub Injury4AgeRange3TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury4AgeRange3TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(4), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE3, value)

    End Sub

    Protected Sub Injury4AgeRange4TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury4AgeRange4TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(4), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE4, value)

    End Sub

    Protected Sub Injury4AgeRange5TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury4AgeRange5TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(4), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE5, value)

    End Sub

    Protected Sub Injury4AgeRange6TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury4AgeRange6TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(4), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE6, value)

    End Sub

    Protected Sub Injury4AgeRange7TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury4AgeRange7TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(4), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE7, value)

    End Sub



    'injury5
    Protected Sub Injury5AgeRange1TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury5AgeRange1TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(5), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE1, value)

    End Sub

    Protected Sub Injury5AgeRange2TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury5AgeRange2TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(5), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE2, value)

    End Sub

    Protected Sub Injury5AgeRange3TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury5AgeRange3TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(5), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE3, value)

    End Sub

    Protected Sub Injury5AgeRange4TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury5AgeRange4TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(5), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE4, value)

    End Sub

    Protected Sub Injury5AgeRange5TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury5AgeRange5TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(5), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE5, value)

    End Sub

    Protected Sub Injury5AgeRange6TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury5AgeRange6TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(5), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE6, value)

    End Sub

    Protected Sub Injury5AgeRange7TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury5AgeRange7TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(5), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE7, value)

    End Sub



    'injury6
    Protected Sub Injury6AgeRange1TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury6AgeRange1TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(6), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE1, value)

    End Sub

    Protected Sub Injury6AgeRange2TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury6AgeRange2TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(6), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE2, value)

    End Sub

    Protected Sub Injury6AgeRange3TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury6AgeRange3TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(6), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE3, value)

    End Sub

    Protected Sub Injury6AgeRange4TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury6AgeRange4TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(6), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE4, value)

    End Sub

    Protected Sub Injury6AgeRange5TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury6AgeRange5TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(6), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE5, value)

    End Sub

    Protected Sub Injury6AgeRange6TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury6AgeRange6TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(6), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE6, value)

    End Sub

    Protected Sub Injury6AgeRange7TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury6AgeRange7TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(6), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE7, value)

    End Sub



    'injury7
    Protected Sub Injury7AgeRange1TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury7AgeRange1TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(7), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE1, value)

    End Sub

    Protected Sub Injury7AgeRange2TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury7AgeRange2TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(7), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE2, value)

    End Sub

    Protected Sub Injury7AgeRange3TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury7AgeRange3TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(7), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE3, value)

    End Sub

    Protected Sub Injury7AgeRange4TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury7AgeRange4TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(7), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE4, value)

    End Sub

    Protected Sub Injury7AgeRange5TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury7AgeRange5TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(7), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE5, value)

    End Sub

    Protected Sub Injury7AgeRange6TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury7AgeRange6TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(7), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE6, value)

    End Sub

    Protected Sub Injury7AgeRange7TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury7AgeRange7TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(7), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE7, value)

    End Sub



    'injury8
    Protected Sub Injury8AgeRange1TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury8AgeRange1TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(8), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE1, value)

    End Sub

    Protected Sub Injury8AgeRange2TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury8AgeRange2TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(8), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE2, value)

    End Sub

    Protected Sub Injury8AgeRange3TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury8AgeRange3TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(8), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE3, value)

    End Sub

    Protected Sub Injury8AgeRange4TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury8AgeRange4TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(8), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE4, value)

    End Sub

    Protected Sub Injury8AgeRange5TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury8AgeRange5TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(8), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE5, value)

    End Sub

    Protected Sub Injury8AgeRange6TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury8AgeRange6TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(8), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE6, value)

    End Sub

    Protected Sub Injury8AgeRange7TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury8AgeRange7TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(8), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE7, value)

    End Sub



    'injury9
    Protected Sub Injury9AgeRange1TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury9AgeRange1TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(9), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE1, value)

    End Sub

    Protected Sub Injury9AgeRange2TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury9AgeRange2TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(9), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE2, value)

    End Sub

    Protected Sub Injury9AgeRange3TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury9AgeRange3TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(9), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE3, value)

    End Sub

    Protected Sub Injury9AgeRange4TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury9AgeRange4TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(9), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE4, value)

    End Sub

    Protected Sub Injury9AgeRange5TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury9AgeRange5TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(9), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE5, value)

    End Sub

    Protected Sub Injury9AgeRange6TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury9AgeRange6TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(9), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE6, value)

    End Sub

    Protected Sub Injury9AgeRange7TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury9AgeRange7TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(9), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE7, value)

    End Sub



    'injury10
    Protected Sub Injury10AgeRange1TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury10AgeRange1TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(10), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE1, value)

    End Sub

    Protected Sub Injury10AgeRange2TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury10AgeRange2TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(10), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE2, value)

    End Sub

    Protected Sub Injury10AgeRange3TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury10AgeRange3TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(10), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE3, value)

    End Sub

    Protected Sub Injury10AgeRange4TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury10AgeRange4TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(10), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE4, value)

    End Sub

    Protected Sub Injury10AgeRange5TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury10AgeRange5TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(10), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE5, value)

    End Sub

    Protected Sub Injury10AgeRange6TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury10AgeRange6TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(10), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE6, value)

    End Sub

    Protected Sub Injury10AgeRange7TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury10AgeRange7TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(10), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE7, value)

    End Sub

    'injury1
    Protected Sub Injury11AgeRange1TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury11AgeRange1TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(11), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE1, value)

    End Sub

    Protected Sub Injury11AgeRange2TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury11AgeRange2TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(11), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE2, value)

    End Sub

    Protected Sub Injury11AgeRange3TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury11AgeRange3TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(11), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE3, value)

    End Sub

    Protected Sub Injury11AgeRange4TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury11AgeRange4TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(11), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE4, value)

    End Sub

    Protected Sub Injury11AgeRange5TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury11AgeRange5TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(11), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE5, value)

    End Sub

    Protected Sub Injury11AgeRange6TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury11AgeRange6TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(11), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE6, value)

    End Sub

    Protected Sub Injury11AgeRange7TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury11AgeRange7TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(11), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE7, value)

    End Sub




    'injury2
    Protected Sub Injury12AgeRange1TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury12AgeRange1TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(12), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE1, value)

    End Sub

    Protected Sub Injury12AgeRange2TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury12AgeRange2TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(12), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE2, value)

    End Sub

    Protected Sub Injury12AgeRange3TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury12AgeRange3TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(12), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE3, value)

    End Sub

    Protected Sub Injury12AgeRange4TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury12AgeRange4TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(12), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE4, value)

    End Sub

    Protected Sub Injury12AgeRange5TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury12AgeRange5TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(12), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE5, value)

    End Sub

    Protected Sub Injury12AgeRange6TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury12AgeRange6TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(12), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE6, value)

    End Sub

    Protected Sub Injury12AgeRange7TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury12AgeRange7TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(12), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE7, value)

    End Sub


    'injury3
    Protected Sub Injury13AgeRange1TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury13AgeRange1TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(13), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE1, value)

    End Sub

    Protected Sub Injury13AgeRange2TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury13AgeRange2TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(13), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE2, value)

    End Sub

    Protected Sub Injury13AgeRange3TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury13AgeRange3TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(13), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE3, value)

    End Sub

    Protected Sub Injury13AgeRange4TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury13AgeRange4TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(13), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE4, value)

    End Sub

    Protected Sub Injury13AgeRange5TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury13AgeRange5TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(13), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE5, value)

    End Sub

    Protected Sub Injury13AgeRange6TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury13AgeRange6TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(13), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE6, value)

    End Sub

    Protected Sub Injury13AgeRange7TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury13AgeRange7TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(13), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE7, value)

    End Sub



    'injury4
    Protected Sub Injury14AgeRange1TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury14AgeRange1TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(14), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE1, value)

    End Sub

    Protected Sub Injury14AgeRange2TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury14AgeRange2TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(14), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE2, value)

    End Sub

    Protected Sub Injury14AgeRange3TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury14AgeRange3TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(14), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE3, value)

    End Sub

    Protected Sub Injury14AgeRange4TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury14AgeRange4TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(14), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE4, value)

    End Sub

    Protected Sub Injury14AgeRange5TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury14AgeRange5TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(14), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE5, value)

    End Sub

    Protected Sub Injury14AgeRange6TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury14AgeRange6TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(14), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE6, value)

    End Sub

    Protected Sub Injury14AgeRange7TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury14AgeRange7TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(14), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE7, value)

    End Sub



    'injury5
    Protected Sub Injury15AgeRange1TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury15AgeRange1TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(15), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE1, value)

    End Sub

    Protected Sub Injury15AgeRange2TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury15AgeRange2TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(15), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE2, value)

    End Sub

    Protected Sub Injury15AgeRange3TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury15AgeRange3TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(15), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE3, value)

    End Sub

    Protected Sub Injury15AgeRange4TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury15AgeRange4TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(15), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE4, value)

    End Sub

    Protected Sub Injury15AgeRange5TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury15AgeRange5TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(15), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE5, value)

    End Sub

    Protected Sub Injury15AgeRange6TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury15AgeRange6TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(15), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE6, value)

    End Sub

    Protected Sub Injury15AgeRange7TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury15AgeRange7TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(15), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE7, value)

    End Sub



    'injury6
    Protected Sub Injury16AgeRange1TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury16AgeRange1TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(16), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE1, value)

    End Sub

    Protected Sub Injury16AgeRange2TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury16AgeRange2TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(16), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE2, value)

    End Sub

    Protected Sub Injury16AgeRange3TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury16AgeRange3TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(16), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE3, value)

    End Sub

    Protected Sub Injury16AgeRange4TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury16AgeRange4TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(16), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE4, value)

    End Sub

    Protected Sub Injury16AgeRange5TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury16AgeRange5TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(16), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE5, value)

    End Sub

    Protected Sub Injury16AgeRange6TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury16AgeRange6TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(16), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE6, value)

    End Sub

    Protected Sub Injury16AgeRange7TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury16AgeRange7TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(16), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE7, value)

    End Sub



    'injury7
    Protected Sub Injury17AgeRange1TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury17AgeRange1TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(17), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE1, value)

    End Sub

    Protected Sub Injury17AgeRange2TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury17AgeRange2TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(17), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE2, value)

    End Sub

    Protected Sub Injury17AgeRange3TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury17AgeRange3TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(17), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE3, value)

    End Sub

    Protected Sub Injury17AgeRange4TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury17AgeRange4TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(17), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE4, value)

    End Sub

    Protected Sub Injury17AgeRange5TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury17AgeRange5TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(17), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE5, value)

    End Sub

    Protected Sub Injury17AgeRange6TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury17AgeRange6TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(17), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE6, value)

    End Sub

    Protected Sub Injury17AgeRange7TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury17AgeRange7TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(17), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE7, value)

    End Sub



    'injury8
    Protected Sub Injury18AgeRange1TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury18AgeRange1TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(18), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE1, value)

    End Sub

    Protected Sub Injury18AgeRange2TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury18AgeRange2TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(18), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE2, value)

    End Sub

    Protected Sub Injury18AgeRange3TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury18AgeRange3TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(18), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE3, value)

    End Sub

    Protected Sub Injury18AgeRange4TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury18AgeRange4TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(18), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE4, value)

    End Sub

    Protected Sub Injury18AgeRange5TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury18AgeRange5TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(18), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE5, value)

    End Sub

    Protected Sub Injury18AgeRange6TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury18AgeRange6TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(18), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE6, value)

    End Sub

    Protected Sub Injury18AgeRange7TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury18AgeRange7TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(18), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE7, value)

    End Sub



    'injury9
    Protected Sub Injury19AgeRange1TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury19AgeRange1TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(19), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE1, value)

    End Sub

    Protected Sub Injury19AgeRange2TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury19AgeRange2TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(19), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE2, value)

    End Sub

    Protected Sub Injury19AgeRange3TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury19AgeRange3TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(19), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE3, value)

    End Sub

    Protected Sub Injury19AgeRange4TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury19AgeRange4TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(19), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE4, value)

    End Sub

    Protected Sub Injury19AgeRange5TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury19AgeRange5TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(19), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE5, value)

    End Sub

    Protected Sub Injury19AgeRange6TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury19AgeRange6TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(19), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE6, value)

    End Sub

    Protected Sub Injury19AgeRange7TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury19AgeRange7TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(19), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE7, value)

    End Sub



    'injury10
    Protected Sub Injury20AgeRange1TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury20AgeRange1TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(20), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE1, value)

    End Sub

    Protected Sub Injury20AgeRange2TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury20AgeRange2TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(20), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE2, value)

    End Sub

    Protected Sub Injury20AgeRange3TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury20AgeRange3TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(20), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE3, value)

    End Sub

    Protected Sub Injury20AgeRange4TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury20AgeRange4TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(20), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE4, value)

    End Sub

    Protected Sub Injury20AgeRange5TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury20AgeRange5TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(20), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE5, value)

    End Sub

    Protected Sub Injury20AgeRange6TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury20AgeRange6TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(20), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE6, value)

    End Sub

    Protected Sub Injury20AgeRange7TxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Injury20AgeRange7TxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        injuriesIDCol = ViewState.Item(injuriesIDColKey)
        Dim injuryID As Integer = CType(injuriesIDCol.Item(20), Base).ID
        UpdateAgeRangeForInjury(injuryID, Cons.AGERANGE7, value)

    End Sub
#End Region


#Region "CHECKing player selection boxes"
    Private Sub UpdatePlayerSelectionsForSimulation(ByVal sender As CheckBox, ByVal player As String, ByVal indx As Integer)

        playersIDCol = ViewState.Item(playersIDColKey)
        Dim value As Integer = -1

        If (sender.Checked = True) Then
            value = CType(playersIDCol.Item(indx), Base).ID

        End If

        CType(GetSimulationByID(ViewState.Item(currentSimulationID)).Setup, SimulationSetup).PlayerMap.Item(player) = value

    End Sub

    Protected Sub Player1Chb_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player1Chb.CheckedChanged
        UpdatePlayerSelectionsForSimulation(sender, Cons.PLAYER1, 1)
    End Sub
    Protected Sub Player2Chb_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player2Chb.CheckedChanged
        UpdatePlayerSelectionsForSimulation(sender, Cons.PLAYER2, 2)
    End Sub
    Protected Sub Player3Chb_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player3Chb.CheckedChanged
        UpdatePlayerSelectionsForSimulation(sender, Cons.PLAYER3, 3)
    End Sub
    Protected Sub Player4Chb_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player4Chb.CheckedChanged
        UpdatePlayerSelectionsForSimulation(sender, Cons.PLAYER4, 4)
    End Sub
    Protected Sub Player5Chb_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player5Chb.CheckedChanged
        UpdatePlayerSelectionsForSimulation(sender, Cons.PLAYER5, 5)
    End Sub
    Protected Sub Player6Chb_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player6Chb.CheckedChanged
        UpdatePlayerSelectionsForSimulation(sender, Cons.PLAYER6, 6)
    End Sub
    Protected Sub Player7Chb_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player7Chb.CheckedChanged
        UpdatePlayerSelectionsForSimulation(sender, Cons.PLAYER7, 7)
    End Sub
    Protected Sub Player8Chb_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player8Chb.CheckedChanged
        UpdatePlayerSelectionsForSimulation(sender, Cons.PLAYER8, 8)
    End Sub
    Protected Sub Player9Chb_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player9Chb.CheckedChanged
        UpdatePlayerSelectionsForSimulation(sender, Cons.PLAYER9, 9)
    End Sub
    Protected Sub Player10Chb_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player10Chb.CheckedChanged
        UpdatePlayerSelectionsForSimulation(sender, Cons.PLAYER10, 10)
    End Sub


    Protected Sub Player11Chb_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player11Chb.CheckedChanged
        UpdatePlayerSelectionsForSimulation(sender, Cons.PLAYER11, 11)
    End Sub
    Protected Sub Player12Chb_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player12Chb.CheckedChanged
        UpdatePlayerSelectionsForSimulation(sender, Cons.PLAYER12, 12)
    End Sub
    Protected Sub Player13Chb_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player13Chb.CheckedChanged
        UpdatePlayerSelectionsForSimulation(sender, Cons.PLAYER13, 13)
    End Sub
    Protected Sub Player14Chb_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player14Chb.CheckedChanged
        UpdatePlayerSelectionsForSimulation(sender, Cons.PLAYER14, 14)
    End Sub
    Protected Sub Player15Chb_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player15Chb.CheckedChanged
        UpdatePlayerSelectionsForSimulation(sender, Cons.PLAYER15, 15)
    End Sub
    Protected Sub Player16Chb_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player16Chb.CheckedChanged
        UpdatePlayerSelectionsForSimulation(sender, Cons.PLAYER16, 16)
    End Sub
    Protected Sub Player17Chb_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player17Chb.CheckedChanged
        UpdatePlayerSelectionsForSimulation(sender, Cons.PLAYER17, 17)
    End Sub
    Protected Sub Player18Chb_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player18Chb.CheckedChanged
        UpdatePlayerSelectionsForSimulation(sender, Cons.PLAYER18, 18)
    End Sub
    Protected Sub Player19Chb_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player19Chb.CheckedChanged
        UpdatePlayerSelectionsForSimulation(sender, Cons.PLAYER19, 19)
    End Sub
    Protected Sub Player20Chb_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player20Chb.CheckedChanged
        UpdatePlayerSelectionsForSimulation(sender, Cons.PLAYER20, 20)
    End Sub

    Protected Sub Player21Chb_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player21Chb.CheckedChanged
        UpdatePlayerSelectionsForSimulation(sender, Cons.PLAYER21, 21)
    End Sub
    Protected Sub Player22Chb_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player22Chb.CheckedChanged
        UpdatePlayerSelectionsForSimulation(sender, Cons.PLAYER22, 22)
    End Sub
    Protected Sub Player23Chb_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player23Chb.CheckedChanged
        UpdatePlayerSelectionsForSimulation(sender, Cons.PLAYER23, 23)
    End Sub
    Protected Sub Player24Chb_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player24Chb.CheckedChanged
        UpdatePlayerSelectionsForSimulation(sender, Cons.PLAYER24, 24)
    End Sub
    Protected Sub Player25Chb_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player25Chb.CheckedChanged
        UpdatePlayerSelectionsForSimulation(sender, Cons.PLAYER25, 25)
    End Sub
    Protected Sub Player26Chb_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player26Chb.CheckedChanged
        UpdatePlayerSelectionsForSimulation(sender, Cons.PLAYER26, 26)
    End Sub
    Protected Sub Player27Chb_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player27Chb.CheckedChanged
        UpdatePlayerSelectionsForSimulation(sender, Cons.PLAYER27, 27)
    End Sub
    Protected Sub Player28Chb_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player28Chb.CheckedChanged
        UpdatePlayerSelectionsForSimulation(sender, Cons.PLAYER28, 28)
    End Sub
    Protected Sub Player29Chb_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player29Chb.CheckedChanged
        UpdatePlayerSelectionsForSimulation(sender, Cons.PLAYER29, 29)
    End Sub
    Protected Sub Player30Chb_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Player30Chb.CheckedChanged
        UpdatePlayerSelectionsForSimulation(sender, Cons.PLAYER30, 30)
    End Sub



#End Region


    'Update Training
    Private Sub UpdateTraining(ByVal sender As TextBox, ByVal key As String)

        Dim value As Double = CleanDouble(sender.Text)

        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).TrainingAgeMap.Item(key) = value

    End Sub

#Region "training other"

    Protected Sub IdealGrowthTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles IdealGrowthTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)
        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).PointsForFUllTraining = value
    End Sub

    'rad
    Protected Sub TrainingAttribute_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TrainingAttribute.CheckedChanged

        Dim sel As String
        Dim sel2 As String
        If (CType(sender, RadioButton).Checked) Then
            sel = Cons.TRAINING_TYPE_Attribute
            sel2 = AttributesList.SelectedItem.Text

        Else
            sel = Cons.TRAINING_TYPE_Category
            sel2 = CategoriesList.SelectedItem.Text

        End If

        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).TrainingType = sel
        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).TrainingTypeSelected = sel2

    End Sub

    'rad
    Protected Sub TrainingCategory_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TrainingCategory.CheckedChanged

        Dim sel As String
        Dim sel2 As String
        If (CType(sender, RadioButton).Checked) Then
            sel = Cons.TRAINING_TYPE_Category
            sel2 = CategoriesList.SelectedItem.Text
        Else
            sel = Cons.TRAINING_TYPE_Attribute
            sel2 = AttributesList.SelectedItem.Text
        End If

        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).TrainingType = sel
        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).TrainingTypeSelected = sel2

    End Sub

    'combox
    Private Sub AttributesList_SelectionChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AttributesList.SelectedIndexChanged
        Dim sel As String = CType(sender, DropDownList).SelectedItem.Text


        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).TrainingTypeSelected = sel

    End Sub


    'combox
    Private Sub CategoriesList_SelectionChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CategoriesList.SelectedIndexChanged

        Dim sel As String = CType(sender, DropDownList).SelectedItem.Text


        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).TrainingTypeSelected = sel

    End Sub

    'rad
    Protected Sub TrainingPositions_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TrainingPositions.CheckedChanged

        Dim sel As String
        If (CType(sender, RadioButton).Checked) Then
            sel = Cons.TRAINING_AFFECTING_Positions
        Else
            sel = Cons.TRAINING_AFFECTING_Zones
        End If

        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).TrainingAffecting = sel
    End Sub

    'rad
    Protected Sub TrainingZones_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TrainingZones.CheckedChanged
        Dim sel As String
        If (CType(sender, RadioButton).Checked) Then
            sel = Cons.TRAINING_AFFECTING_Zones
        Else
            sel = Cons.TRAINING_AFFECTING_Positions
        End If

        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).TrainingAffecting = sel

        '
    End Sub



    'positions
    Protected Sub GKTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GKTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)

        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).GK = value

    End Sub

    Protected Sub SWTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles SWTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)

        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).SW = value

    End Sub

    Protected Sub RBTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RBTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)

        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).RB = value

    End Sub

    Protected Sub RWBTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RWBTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)

        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).RWB = value

    End Sub

    Protected Sub RCBTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RCBTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)

        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).RCB = value

    End Sub

    Protected Sub CBTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles CBTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)

        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).CB = value

    End Sub

    Protected Sub LCBTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles LCBTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)

        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).LCB = value

    End Sub

    Protected Sub LWBTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles LWBTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)

        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).LWB = value

    End Sub

    Protected Sub LBTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles LBTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)

        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).LB = value

    End Sub



    Protected Sub RMTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RMTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)

        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).RM = value

    End Sub

    Protected Sub RAMTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RAMTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)

        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).RAM = value

    End Sub

    Protected Sub RCMTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RCMTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)

        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).RCM = value

    End Sub

    Protected Sub RDMTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RDMTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)

        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).RDM = value

    End Sub

    Protected Sub LDMTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles LDMTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)

        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).LDM = value

    End Sub

    Protected Sub CMTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles CMTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)

        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).CM = value

    End Sub

    Protected Sub CAMTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles CAMTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)

        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).CAM = value

    End Sub

    Protected Sub CDMTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles CDMTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)

        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).CDM = value

    End Sub

    Protected Sub LCMTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles LCMTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)

        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).LCM = value

    End Sub

    Protected Sub LAMTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles LAMTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)

        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).LAM = value

    End Sub

    Protected Sub LMTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles LMTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)

        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).LM = value

    End Sub




    Protected Sub RWTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RWTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)

        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).RW = value

    End Sub

    Protected Sub RFTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RFTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)

        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).RF = value

    End Sub

    Protected Sub RSTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RSTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)

        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).RS = value

    End Sub

    Protected Sub CFTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles CFTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)

        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).CF = value

    End Sub

    Protected Sub STTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles STTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)

        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).ST = value

    End Sub

    Protected Sub LSTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles LSTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)

        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).LS = value

    End Sub

    Protected Sub LFTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles LFTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)

        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).LF = value

    End Sub

    Protected Sub LWTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles LWTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)

        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).LW = value

    End Sub



    'zones

    Protected Sub KeeperTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles KeeperTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)

        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).Keeper = value

    End Sub

    Protected Sub DefenseTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DefenseTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)

        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).Defense = value

    End Sub

    Protected Sub MidfieldTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles MidfieldTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)

        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).Midfield = value

    End Sub

    Protected Sub ForwardTxtB_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ForwardTxtB.TextChanged
        Dim value As Integer = CleanInteger(CType(sender, TextBox).Text)

        CType(GetTrainingByID(ViewState.Item(currentTrainingID)).Setup, TrainingSetup).Forward = value

    End Sub


#End Region



    Protected Sub RunSimulationBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles RunSimulationBtn.Click

        Dim engine As New PrivateEngine
        engine.AppData = Server.MapPath("~/App_Data/")

        Dim thread As New Threading.Thread(AddressOf LoadEngine)

        thread.Start(engine)

        'System.Threading.ThreadPool.SetMaxThreads(3, 3)
        'System.Threading.ThreadPool.QueueUserWorkItem(New Threading.WaitCallback(AddressOf LoadEngine), engine)
        ''''engine.Start(CInt(ViewState.Item("currentSimulationID")))


        'Try

        '    Cons.sema.WaitOne()

        '    Dim thread As New Threading.Thread(AddressOf LoadEngine)

        '    thread.Start(engine)

        'Catch ex As Exception


        'Finally

        '    Cons.sema.Release()
        'End Try





    End Sub

    Private Sub LoadEngine(ByVal eng As Object)


        Dim selectedTrainingsCol As Collection
        Dim selectedInjuriesCol As Collection
        Dim selectedPlayersCol As Collection

        Dim simId As Integer = CInt(ViewState.Item("currentSimulationID"))
        Dim simulation As Base = DBConnection.FET_SIMULATION(simId)

        Dim trainingMap As Hashtable = CType(simulation.Setup, SimulationSetup).TrainingMap
        selectedTrainingsCol = New Collection

        For Each value As Object In trainingMap.Values
            If value <> -1 Then
                If (Not selectedTrainingsCol.Contains(value)) Then
                    'validate it first
                    Dim valid As Boolean = False
                    Dim training As Base = DBConnection.FET_TRAINING(value)
                    Dim trainingErrs As Collection = training.ValidateBase() ' for this training

                    selectedTrainingsCol.Add(DBConnection.FET_TRAINING(value), value)
                End If
            End If

        Next


        Dim injuriesMap As Hashtable = CType(simulation.Setup, SimulationSetup).InjuriesMap
        selectedInjuriesCol = New Collection

        For Each value As Object In injuriesMap.Keys
            If value <> -1 Then
                If (Not selectedInjuriesCol.Contains(value)) Then
                    selectedInjuriesCol.Add(DBConnection.FET_INJURY(value), value)
                End If
            End If
        Next


        Dim playerMap As Hashtable = CType(simulation.Setup, SimulationSetup).PlayerMap
        selectedPlayersCol = New Collection
        For Each value As Object In playerMap.Values
            If value <> -1 Then
                If (Not selectedPlayersCol.Contains(value)) Then
                    selectedPlayersCol.Add(DBConnection.FET_PLAYER(value), value)
                End If

            End If
        Next
        eng.SimID = simId
        eng.SelectedTrainingsCol = selectedTrainingsCol
        eng.SelectedInjuriesCol = selectedInjuriesCol
        eng.SelectedPlayersCol = selectedPlayersCol

        eng.Start() 'must return filename that holds serialized data
    End Sub

    Protected Sub fill()
        CopyPlayerCombox.Items.Clear()

        CopyPlayerCombox.Items.Add("")

        For Each player As Base In DBConnection.FET_PLAYERS(CType(ViewState.Item(userID), User).ID)
            CopyPlayerCombox.Items.Add(player.Name)
        Next

    End Sub

    Private Sub CopyPlayerCombox_SelectionChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyPlayerCombox.SelectedIndexChanged
        Dim sel As String = CType(sender, DropDownList).SelectedItem.Text

        ViewState.Add(copyPlayerID, GetPlayerByName(sel))
        NewPlayerNameTxtB.Text = GetPlayerByName(sel).Name
        NewPlayerDescTxtB.Text = GetPlayerByName(sel).Desc



    End Sub


End Class
